mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: 异常代码
This commit is contained in:
@@ -4,11 +4,20 @@ 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;
|
||||
uin: number;
|
||||
uid: string;
|
||||
nick_name: string;
|
||||
age: number;
|
||||
source: string;
|
||||
}
|
||||
|
||||
interface Block {
|
||||
str_uid: string;
|
||||
bytes_source: string;
|
||||
uint32_sex: number;
|
||||
uint32_age: number;
|
||||
bytes_nick: string;
|
||||
uint64_uin: number;
|
||||
}
|
||||
|
||||
export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
||||
@@ -23,25 +32,25 @@ export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
||||
|
||||
async _handle(): Promise<Friend[]> {
|
||||
const self_id = this.core.selfInfo.uin;
|
||||
const req_json = JSON.stringify({
|
||||
const req_json = {
|
||||
uint64_uin: self_id,
|
||||
uint64_top: 0,
|
||||
uint32_req_num: 99,
|
||||
bytes_cookies: ""
|
||||
});
|
||||
const packed_data = await this.pack_data(req_json);
|
||||
};
|
||||
const packed_data = await this.pack_data(JSON.stringify(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;
|
||||
const block_list: Block[] = 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()
|
||||
return block_list.map((block) => ({
|
||||
uin: block.uint64_uin,
|
||||
uid: block.str_uid,
|
||||
nick_name: Buffer.from(block.bytes_nick, 'base64').toString(),
|
||||
age: block.uint32_age,
|
||||
source: Buffer.from(block.bytes_source, 'base64').toString()
|
||||
}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user