mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix
This commit is contained in:
parent
df6113fdf6
commit
8dd0e60eea
@ -29,10 +29,6 @@ import { NapCatConfigLoader } from '@/core/helper/config';
|
||||
import os from 'node:os';
|
||||
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from '@/core/listeners';
|
||||
import { proxiedListenerOf } from '@/common/proxy-handler';
|
||||
import { Native } from '@/native';
|
||||
import { buffer } from 'stream/consumers';
|
||||
import { Message, MsgHead, RecallGroup } from './proto/Message';
|
||||
|
||||
export * from './wrapper';
|
||||
export * from './entities';
|
||||
export * from './services';
|
||||
@ -80,7 +76,6 @@ export class NapCatCore {
|
||||
|
||||
// 通过构造器递过去的 runtime info 应该尽量少
|
||||
constructor(context: InstanceContext, selfInfo: SelfInfo) {
|
||||
let appNative = new Native(context.pathWrapper.binaryPath);
|
||||
this.selfInfo = selfInfo;
|
||||
this.context = context;
|
||||
this.util = this.context.wrapper.NodeQQNTWrapperUtil;
|
||||
@ -103,38 +98,7 @@ export class NapCatCore {
|
||||
if (!fs.existsSync(this.NapCatTempPath)) {
|
||||
fs.mkdirSync(this.NapCatTempPath, { recursive: true });
|
||||
}
|
||||
appNative.MoeHooExport.exports.registMsgPush(async (hex: string) => {
|
||||
try {
|
||||
let data = Message.decode(Buffer.from(hex, 'hex')) as any;
|
||||
//data.MsgHead.BodyInner.MsgType SubType
|
||||
let bodyInner = data.msgHead.bodyInner;
|
||||
//context.logger.log("[appNative] Parse MsgType:" + bodyInner.msgType + " / SubType:" + bodyInner.subType);
|
||||
if (bodyInner.msgType == 732 && bodyInner.subType == 17) {
|
||||
let RecallData = Buffer.from(data.msgHead.noifyData.innerData);
|
||||
//跳过 4字节 群号 + 不知道的1字节 +2字节 长度
|
||||
let uid = RecallData.readUint32BE();
|
||||
const buffer = Buffer.from(RecallData.toString('hex').slice(14), 'hex');
|
||||
let seq: number = (RecallGroup.decode(buffer) as any).msgSeq;
|
||||
let peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: uid.toString() };
|
||||
context.logger.log("[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq);
|
||||
let msgs = await this.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, seq.toString())
|
||||
console.log(JSON.stringify(msgs, null, 4));
|
||||
// this.apis.MsgApi.sendMsg(peer, [{
|
||||
// elementType: 1,
|
||||
// elementId: '',
|
||||
// textElement: {
|
||||
// content: "[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq,
|
||||
// atType: 0,
|
||||
// atUid: '',
|
||||
// atTinyId: '',
|
||||
// atNtUid: '',
|
||||
// },
|
||||
// }]);
|
||||
}
|
||||
} catch (error: any) {
|
||||
context.logger.logWarn("[appNative]", (error as Error).message);
|
||||
}
|
||||
});
|
||||
|
||||
this.initNapCatCoreListeners().then().catch(this.context.logger.logError.bind(this.context.logger));
|
||||
|
||||
this.context.logger.setFileLogEnabled(
|
||||
|
BIN
src/native/external/MoeHoo.win32.node
vendored
BIN
src/native/external/MoeHoo.win32.node
vendored
Binary file not shown.
@ -10,6 +10,7 @@ import {
|
||||
NodeIKernelBuddyListener,
|
||||
NodeIKernelGroupListener,
|
||||
NodeIKernelMsgListener,
|
||||
Peer,
|
||||
RawMessage,
|
||||
SendStatusType,
|
||||
} from '@/core';
|
||||
@ -43,8 +44,10 @@ import { OB11FriendRecallNoticeEvent } from '@/onebot/event/notice/OB11FriendRec
|
||||
import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecallNoticeEvent';
|
||||
import { LRUCache } from '@/common/lru-cache';
|
||||
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
||||
import { OB11ProfileLikeEvent } from './event/notice/OB11ProfileLikeEvent';
|
||||
import { profileLikeTip, ProfileLikeTipType, SysMessage, SysMessageType } from '@/core/proto/ProfileLike';
|
||||
import { Native } from '@/native';
|
||||
import { Message, RecallGroup } from '@/core/proto/Message';
|
||||
import { OB11MessageData } from './types';
|
||||
|
||||
//OneBot实现类
|
||||
export class NapCatOneBot11Adapter {
|
||||
readonly core: NapCatCore;
|
||||
@ -70,10 +73,52 @@ export class NapCatOneBot11Adapter {
|
||||
};
|
||||
this.actions = createActionMap(this, core);
|
||||
this.networkManager = new OB11NetworkManager();
|
||||
this.registerNative(core,context).then().catch();
|
||||
this.InitOneBot()
|
||||
.catch(e => this.context.logger.logError.bind(this.context.logger)('初始化OneBot失败', e));
|
||||
}
|
||||
|
||||
}
|
||||
async registerNative(core: NapCatCore, context: InstanceContext) {
|
||||
let appNative = new Native(context.pathWrapper.binaryPath);
|
||||
appNative.MoeHooExport.exports.registMsgPush(async (hex: string) => {
|
||||
try {
|
||||
let data = Message.decode(Buffer.from(hex, 'hex')) as any;
|
||||
//data.MsgHead.BodyInner.MsgType SubType
|
||||
let bodyInner = data.msgHead?.bodyInner;
|
||||
//context.logger.log("[appNative] Parse MsgType:" + bodyInner.msgType + " / SubType:" + bodyInner.subType);
|
||||
if (bodyInner && bodyInner.msgType == 732 && bodyInner.subType == 17) {
|
||||
let RecallData = Buffer.from(data.msgHead.noifyData.innerData);
|
||||
//跳过 4字节 群号 + 不知道的1字节 +2字节 长度
|
||||
let uid = RecallData.readUint32BE();
|
||||
const buffer = Buffer.from(RecallData.toString('hex').slice(14), 'hex');
|
||||
let seq: number = (RecallGroup.decode(buffer) as any).msgSeq;
|
||||
let peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: uid.toString() };
|
||||
context.logger.log("[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq);
|
||||
let msgs = await core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, seq.toString());
|
||||
let ob11 = await this.apis.MsgApi.parseMessage(msgs.msgList[0], 'array')
|
||||
if (ob11) {
|
||||
const { sendElements, deleteAfterSentFiles } = await this.apis.MsgApi.createSendElements(ob11.message as OB11MessageData[], peer);
|
||||
this.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, deleteAfterSentFiles);
|
||||
}
|
||||
|
||||
|
||||
// this.apis.MsgApi.sendMsg(peer, [{
|
||||
// elementType: 1,
|
||||
// elementId: '',
|
||||
// textElement: {
|
||||
// content: "[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq,
|
||||
// atType: 0,
|
||||
// atUid: '',
|
||||
// atTinyId: '',
|
||||
// atNtUid: '',
|
||||
// },
|
||||
// }]);
|
||||
}
|
||||
} catch (error: any) {
|
||||
context.logger.logWarn("[appNative]", (error as Error).message);
|
||||
}
|
||||
});
|
||||
}
|
||||
async InitOneBot() {
|
||||
const selfInfo = this.core.selfInfo;
|
||||
const ob11Config = this.configLoader.configData;
|
||||
|
Loading…
x
Reference in New Issue
Block a user