mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix
This commit is contained in:
parent
274c956f16
commit
476d8ba14d
@ -6,7 +6,7 @@ import { PacketClient } from '../helper/packet';
|
||||
import { NapProtoMsg } from '../proto/NapProto';
|
||||
import { OidbSvcTrpcTcp0X9067_202 } from '../proto/oidb/Oidb.0x9067_202';
|
||||
import { OidbSvcTrpcTcpBase } from '../proto/oidb/OidbBase';
|
||||
import { OidbSvcTrpcTcp0XFE1_2 } from '../proto/oidb/Oidb.fe1_2';
|
||||
import { OidbSvcTrpcTcp0XFE1_2, OidbSvcTrpcTcp0XFE1_2RSP } from '../proto/oidb/Oidb.fe1_2';
|
||||
|
||||
interface OffsetType {
|
||||
[key: string]: {
|
||||
@ -54,7 +54,7 @@ export class NTQQPacketApi {
|
||||
}
|
||||
return text;
|
||||
}
|
||||
async sendPacket(cmd: string, data: string, rsp = false) {
|
||||
async sendPacket(cmd: string, data: string, rsp = false): Promise<any> {
|
||||
// wtfk tx
|
||||
// 校验失败和异常 可能返回undefined
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -109,4 +109,24 @@ export class NTQQPacketApi {
|
||||
});
|
||||
return oidb_packet;
|
||||
}
|
||||
async sendStatusPacket(uin: number): Promise<{ status: number; ext_status: number; } | undefined> {
|
||||
let status = 0;
|
||||
try {
|
||||
let packet = Buffer.from(await this.core.apis.PacketApi.buildStatusPacket(uin)).toString('hex');
|
||||
let ret = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xfe1_2', packet, true);
|
||||
console.log('ret: ', ret);
|
||||
let data = Buffer.from(ret.hex_data, 'hex');
|
||||
let ext = new NapProtoMsg(OidbSvcTrpcTcp0XFE1_2RSP).decode(new NapProtoMsg(OidbSvcTrpcTcpBase).decode(data).body).data.status.value;
|
||||
// ext & 0xff00 + ext >> 16 & 0xff
|
||||
let extBigInt = BigInt(ext); // 转换为 BigInt
|
||||
if (extBigInt <= 10n) {
|
||||
return { status: Number(extBigInt) * 10, ext_status: 0 };
|
||||
}
|
||||
status = Number((extBigInt & 0xff00n) + ((extBigInt >> 16n) & 0xffn)); // 使用 BigInt 操作符
|
||||
return { status: 10, ext_status: status };
|
||||
} catch (error) {
|
||||
return undefined
|
||||
}
|
||||
return { status: status, ext_status: 0 };
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import {ScalarType} from "@protobuf-ts/runtime";
|
||||
import {ProtoField} from "../NapProto";
|
||||
import { ScalarType } from "@protobuf-ts/runtime";
|
||||
import { ProtoField } from "../NapProto";
|
||||
|
||||
export const OidbSvcTrpcTcp0XFE1_2 = {
|
||||
uin: ProtoField(1, ScalarType.UINT32),
|
||||
@ -9,3 +9,15 @@ export const OidbSvcTrpcTcp0XFE1_2 = {
|
||||
export const OidbSvcTrpcTcp0XFE1_2Key = {
|
||||
key: ProtoField(1, ScalarType.UINT32)
|
||||
}
|
||||
export const OidbSvcTrpcTcp0XFE1_2RSP_Status = {
|
||||
key: ProtoField(1, ScalarType.UINT32),
|
||||
value: ProtoField(2, ScalarType.UINT64)
|
||||
}
|
||||
|
||||
export const OidbSvcTrpcTcp0XFE1_2RSP_Data = {
|
||||
status: ProtoField(2, () => OidbSvcTrpcTcp0XFE1_2RSP_Status)
|
||||
}
|
||||
|
||||
export const OidbSvcTrpcTcp0XFE1_2RSP = {
|
||||
data: ProtoField(1, () => OidbSvcTrpcTcp0XFE1_2RSP_Data)
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import { LRUCache } from '@/common/lru-cache';
|
||||
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
||||
import { Native } from '@/native';
|
||||
import { decodeMessage, decodeRecallGroup, Message, RecallGroup } from '@/core/proto/old/Message';
|
||||
import { OB11MessageDataType } from './types';
|
||||
|
||||
//OneBot实现类
|
||||
export class NapCatOneBot11Adapter {
|
||||
@ -540,10 +541,26 @@ 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('!status')) {
|
||||
console.log('status', message.peerUin, message.senderUin);
|
||||
let delMsg: string[] = [];
|
||||
let peer = {
|
||||
peerUid: message.peerUin,
|
||||
chatType: 2,
|
||||
};
|
||||
this.core.apis.PacketApi.sendStatusPacket(+message.senderUin).then(async e => {
|
||||
if (e) {
|
||||
const { sendElements } = await this.apis.MsgApi.createSendElements([{
|
||||
type: OB11MessageDataType.text,
|
||||
data: {
|
||||
text: 'status ' + JSON.stringify(e, null, 2),
|
||||
}
|
||||
}], peer)
|
||||
|
||||
this.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, delMsg)
|
||||
}
|
||||
})
|
||||
}
|
||||
this.networkManager.emitEvent(ob11Msg);
|
||||
}).catch(e => this.context.logger.logError.bind(this.context.logger)('constructMessage error: ', e));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user