mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-19 21:20:07 +08:00
fix: #791
This commit is contained in:
parent
cf5e0e0f14
commit
c8b268b806
@ -65,6 +65,7 @@
|
|||||||
"@ffmpeg.wasm/core-mt": "^0.13.2",
|
"@ffmpeg.wasm/core-mt": "^0.13.2",
|
||||||
"compressing": "^1.10.1",
|
"compressing": "^1.10.1",
|
||||||
"express": "^5.0.0",
|
"express": "^5.0.0",
|
||||||
|
"napcat.protobuf": "^1.1.3",
|
||||||
"piscina": "^4.7.0",
|
"piscina": "^4.7.0",
|
||||||
"silk-wasm": "^3.6.1",
|
"silk-wasm": "^3.6.1",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
|
|||||||
47
src/onebot/action/extends/GetUnidirectionalFriendList.ts
Normal file
47
src/onebot/action/extends/GetUnidirectionalFriendList.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { PacketHexStr } from '@/core/packet/transformer/base';
|
||||||
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { ProtoBuf, ProtoBufBase, PBUint32, PBString } from 'napcat.protobuf';
|
||||||
|
|
||||||
|
interface Friend {
|
||||||
|
Uin: number;
|
||||||
|
UID: number;
|
||||||
|
Nickname: string;
|
||||||
|
Age: number;
|
||||||
|
Source: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
||||||
|
override actionName = ActionName.GetUnidirectionalFriendList;
|
||||||
|
|
||||||
|
async pack_data(data: string): Promise<Uint8Array> {
|
||||||
|
return ProtoBuf(class extends ProtoBufBase {
|
||||||
|
type = PBUint32(2, false, 0);
|
||||||
|
data = PBString(3, false, data);
|
||||||
|
}).encode();
|
||||||
|
}
|
||||||
|
|
||||||
|
async _handle(): Promise<Friend[]> {
|
||||||
|
const self_id = this.core.selfInfo.uin;
|
||||||
|
const req_json = JSON.stringify({
|
||||||
|
uint64_uin: self_id,
|
||||||
|
uint64_top: 0,
|
||||||
|
uint32_req_num: 99,
|
||||||
|
bytes_cookies: ""
|
||||||
|
});
|
||||||
|
const packed_data = await this.pack_data(req_json);
|
||||||
|
const data = Buffer.from(packed_data).toString('hex');
|
||||||
|
const rsq = { cmd: 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0', data: data as PacketHexStr };
|
||||||
|
const rsp_data = await this.core.apis.PacketApi.pkt.operation.sendPacket(rsq, true);
|
||||||
|
const block_json = ProtoBuf(class extends ProtoBufBase { data = PBString(4); }).decode(rsp_data);
|
||||||
|
const block_list = JSON.parse(block_json.data).rpt_block_list;
|
||||||
|
|
||||||
|
return block_list.map((block: any) => ({
|
||||||
|
Uin: block.Uin,
|
||||||
|
UID: block.UID,
|
||||||
|
Nickname: Buffer.from(block.NickBytes, 'base64').toString(),
|
||||||
|
Age: block.Age,
|
||||||
|
Source: Buffer.from(block.SourceBytes, 'base64').toString()
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -107,6 +107,7 @@ import { SetDiyOnlineStatus } from './extends/SetDiyOnlineStatus';
|
|||||||
import { BotExit } from './extends/BotExit';
|
import { BotExit } from './extends/BotExit';
|
||||||
import { ClickInlineKeyboardButton } from './extends/ClickInlineKeyboardButton';
|
import { ClickInlineKeyboardButton } from './extends/ClickInlineKeyboardButton';
|
||||||
import { GetPrivateFileUrl } from './file/GetPrivateFileUrl';
|
import { GetPrivateFileUrl } from './file/GetPrivateFileUrl';
|
||||||
|
import { GetUnidirectionalFriendList } from './extends/GetUnidirectionalFriendList';
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||||
|
|
||||||
@ -226,7 +227,8 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new GetGroupSystemMsg(obContext, core),
|
new GetGroupSystemMsg(obContext, core),
|
||||||
new BotExit(obContext, core),
|
new BotExit(obContext, core),
|
||||||
new ClickInlineKeyboardButton(obContext, core),
|
new ClickInlineKeyboardButton(obContext, core),
|
||||||
new GetPrivateFileUrl(obContext,core)
|
new GetPrivateFileUrl(obContext,core),
|
||||||
|
new GetUnidirectionalFriendList(obContext,core),
|
||||||
];
|
];
|
||||||
|
|
||||||
type HandlerUnion = typeof actionHandlers[number];
|
type HandlerUnion = typeof actionHandlers[number];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user