Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Oct 12, 2024
1 parent eba5900 commit 968bd7a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/core/apis/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export class NTQQGroupApi {
async sendPacketPoke(group: string, peer: string) {
let data = encodeGroupPoke(group, peer);
let hex = Buffer.from(data).toString('hex');
let retdata = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xed3_1', hex, true);
console.log('sendPacketPoke', retdata);
let retdata = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xed3_1', hex, false);
//console.log('sendPacketPoke', retdata);
}
async fetchGroupEssenceList(groupCode: string) {
const pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
Expand Down
17 changes: 16 additions & 1 deletion src/core/apis/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ export class NTQQPacketApi {
return text;
}
async sendPacket(cmd: string, data: string, rsp = false) {
return new Promise((resolve, reject) => {
// wtfk tx
// 校验失败和异常 可能返回undefined
return new Promise<undefined | {
type: string,//仅recv含有data
trace_id: string,
data: {
trace_id: string,
seq: number,
hex_data: string,
cmd: string
}
}>((resolve, reject) => {
if (!this.isInit || !this.PacketClient?.isConnected) {
this.core.context.logger.logError('PacketClient is not init');
return undefined;
}
let md5 = crypto.createHash('md5').update(data).digest('hex');
let trace_id = (this.randText(4) + md5 + data).slice(0, data.length / 2);
this.PacketClient?.sendCommand(cmd, data, trace_id, rsp, 5000, async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/helper/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import WebSocket from "ws";

export class PacketClient {
private websocket: WebSocket | undefined;
private isConnected: boolean = false;
public isConnected: boolean = false;
private reconnectAttempts: number = 0;
private maxReconnectAttempts: number = 5;
private cb = new LRUCache<string, { type: string, callback: any }>(500);
Expand Down
8 changes: 4 additions & 4 deletions src/onebot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ export class NapCatOneBot11Adapter {
if (isSelfMsg) {
ob11Msg.target_id = parseInt(message.peerUin);
}
if(ob11Msg.raw_message.startsWith('!poke')){
console.log('poke',message.peerUin, message.senderUin);
this.core.apis.GroupApi.sendPacketPoke(message.peerUin, message.senderUin);
}
// if(ob11Msg.raw_message.startsWith('!poke')){
// console.log('poke',message.peerUin, message.senderUin);
// this.core.apis.GroupApi.sendPacketPoke(message.peerUin, message.senderUin);
// }
this.networkManager.emitEvent(ob11Msg);
}).catch(e => this.context.logger.logError.bind(this.context.logger)('constructMessage error: ', e));

Expand Down

0 comments on commit 968bd7a

Please sign in to comment.