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';
|
import { ProtoBuf, ProtoBufBase, PBUint32, PBString } from 'napcat.protobuf';
|
||||||
|
|
||||||
interface Friend {
|
interface Friend {
|
||||||
Uin: number;
|
uin: number;
|
||||||
UID: number;
|
uid: string;
|
||||||
Nickname: string;
|
nick_name: string;
|
||||||
Age: number;
|
age: number;
|
||||||
Source: string;
|
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[]> {
|
export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
||||||
@@ -23,25 +32,25 @@ export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
|||||||
|
|
||||||
async _handle(): Promise<Friend[]> {
|
async _handle(): Promise<Friend[]> {
|
||||||
const self_id = this.core.selfInfo.uin;
|
const self_id = this.core.selfInfo.uin;
|
||||||
const req_json = JSON.stringify({
|
const req_json = {
|
||||||
uint64_uin: self_id,
|
uint64_uin: self_id,
|
||||||
uint64_top: 0,
|
uint64_top: 0,
|
||||||
uint32_req_num: 99,
|
uint32_req_num: 99,
|
||||||
bytes_cookies: ""
|
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 data = Buffer.from(packed_data).toString('hex');
|
||||||
const rsq = { cmd: 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0', data: data as PacketHexStr };
|
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 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_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) => ({
|
return block_list.map((block) => ({
|
||||||
Uin: block.Uin,
|
uin: block.uint64_uin,
|
||||||
UID: block.UID,
|
uid: block.str_uid,
|
||||||
Nickname: Buffer.from(block.NickBytes, 'base64').toString(),
|
nick_name: Buffer.from(block.bytes_nick, 'base64').toString(),
|
||||||
Age: block.Age,
|
age: block.uint32_age,
|
||||||
Source: Buffer.from(block.SourceBytes, 'base64').toString()
|
source: Buffer.from(block.bytes_source, 'base64').toString()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user