mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: onMsgRecall
This commit is contained in:
@@ -255,7 +255,7 @@ export class NodeIKernelMsgListener {
|
||||
|
||||
}
|
||||
|
||||
onMsgRecall(i2: unknown, str: unknown, j2: unknown): any {
|
||||
onMsgRecall(chatType: ChatType, uid: string, msgSeq: string): any {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -40,17 +40,18 @@ export interface FaceElement {
|
||||
surpriseId?: string;
|
||||
randomType?: number;
|
||||
}
|
||||
export interface GrayTipRovokeElement {
|
||||
operatorRole: string;
|
||||
operatorUid: string;
|
||||
operatorNick: string;
|
||||
operatorRemark: string;
|
||||
operatorMemRemark?: string;
|
||||
wording: string; // 自定义的撤回提示语
|
||||
}
|
||||
|
||||
export interface GrayTipElement {
|
||||
subElementType: NTGrayTipElementSubTypeV2;
|
||||
revokeElement: {
|
||||
operatorRole: string;
|
||||
operatorUid: string;
|
||||
operatorNick: string;
|
||||
operatorRemark: string;
|
||||
operatorMemRemark?: string;
|
||||
wording: string; // 自定义的撤回提示语
|
||||
};
|
||||
revokeElement: GrayTipRovokeElement;
|
||||
aioOpGrayTipElement: TipAioOpGrayTipElement;
|
||||
groupElement: TipGroupElement;
|
||||
xmlElement: {
|
||||
|
@@ -666,10 +666,10 @@ export class OneBotMsgApi {
|
||||
}
|
||||
|
||||
async parsePrivateMsgEvent(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||
if (grayTipElement && grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||
if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement);
|
||||
if (PokeEvent) return PokeEvent;
|
||||
if (PokeEvent) { return PokeEvent };
|
||||
} else if (grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') {
|
||||
return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { NapCatCore } from '@/core';
|
||||
import { GrayTipRovokeElement, NapCatCore, RawMessage } from '@/core';
|
||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
import { OB11ProfileLikeEvent } from '@/onebot/event/notice/OB11ProfileLikeEvent';
|
||||
import { decodeProfileLikeTip } from "@/core/helper/adaptDecoder";
|
||||
@@ -11,7 +11,7 @@ export class OneBotUserApi {
|
||||
this.obContext = obContext;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
|
||||
async parseLikeEvent(wrappedBody: Uint8Array): Promise<OB11ProfileLikeEvent | undefined> {
|
||||
const likeTip = decodeProfileLikeTip(Uint8Array.from(wrappedBody));
|
||||
if (likeTip?.msgType !== 0 || likeTip?.subType !== 203) return;
|
||||
|
@@ -265,16 +265,22 @@ export class NapCatOneBot11Adapter {
|
||||
};
|
||||
|
||||
const msgIdSend = new LRUCache<string, number>(100);
|
||||
const recallMsgs = new LRUCache<string, boolean>(100);
|
||||
|
||||
msgListener.onAddSendMsg = async (msg) => {
|
||||
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SENDING) {
|
||||
msgIdSend.put(msg.msgId, 0);
|
||||
}
|
||||
};
|
||||
msgListener.onMsgRecall = async (chatType: ChatType, uid: string, msgSeq: string) => {
|
||||
const peer: Peer = {
|
||||
chatType: chatType,
|
||||
peerUid: uid,
|
||||
guildId: ''
|
||||
};
|
||||
let msg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, msgSeq)).msgList;
|
||||
console.log(JSON.stringify(msg));
|
||||
}
|
||||
msgListener.onMsgInfoListUpdate = async (msgList) => {
|
||||
this.emitRecallMsg(msgList, recallMsgs).catch((e) =>
|
||||
this.context.logger.logError.bind(this.context.logger)('处理消息失败', e)
|
||||
);
|
||||
for (const msg of msgList.filter((e) => e.senderUin == this.core.selfInfo.uin)) {
|
||||
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && msgIdSend.get(msg.msgId) == 0) {
|
||||
msgIdSend.put(msg.msgId, 1);
|
||||
|
Reference in New Issue
Block a user