mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-16 13:20:33 +00:00
refactor: onMsgRecall
This commit is contained in:
parent
a1079dd948
commit
62127b6d48
@ -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;
|
surpriseId?: string;
|
||||||
randomType?: number;
|
randomType?: number;
|
||||||
}
|
}
|
||||||
|
export interface GrayTipRovokeElement {
|
||||||
|
operatorRole: string;
|
||||||
|
operatorUid: string;
|
||||||
|
operatorNick: string;
|
||||||
|
operatorRemark: string;
|
||||||
|
operatorMemRemark?: string;
|
||||||
|
wording: string; // 自定义的撤回提示语
|
||||||
|
}
|
||||||
|
|
||||||
export interface GrayTipElement {
|
export interface GrayTipElement {
|
||||||
subElementType: NTGrayTipElementSubTypeV2;
|
subElementType: NTGrayTipElementSubTypeV2;
|
||||||
revokeElement: {
|
revokeElement: GrayTipRovokeElement;
|
||||||
operatorRole: string;
|
|
||||||
operatorUid: string;
|
|
||||||
operatorNick: string;
|
|
||||||
operatorRemark: string;
|
|
||||||
operatorMemRemark?: string;
|
|
||||||
wording: string; // 自定义的撤回提示语
|
|
||||||
};
|
|
||||||
aioOpGrayTipElement: TipAioOpGrayTipElement;
|
aioOpGrayTipElement: TipAioOpGrayTipElement;
|
||||||
groupElement: TipGroupElement;
|
groupElement: TipGroupElement;
|
||||||
xmlElement: {
|
xmlElement: {
|
||||||
|
|||||||
@ -666,10 +666,10 @@ export class OneBotMsgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parsePrivateMsgEvent(msg: RawMessage, grayTipElement: GrayTipElement) {
|
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) {
|
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement);
|
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 !== '') {
|
} else if (grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') {
|
||||||
return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(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 { NapCatOneBot11Adapter } from '@/onebot';
|
||||||
import { OB11ProfileLikeEvent } from '@/onebot/event/notice/OB11ProfileLikeEvent';
|
import { OB11ProfileLikeEvent } from '@/onebot/event/notice/OB11ProfileLikeEvent';
|
||||||
import { decodeProfileLikeTip } from "@/core/helper/adaptDecoder";
|
import { decodeProfileLikeTip } from "@/core/helper/adaptDecoder";
|
||||||
@ -11,7 +11,7 @@ export class OneBotUserApi {
|
|||||||
this.obContext = obContext;
|
this.obContext = obContext;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseLikeEvent(wrappedBody: Uint8Array): Promise<OB11ProfileLikeEvent | undefined> {
|
async parseLikeEvent(wrappedBody: Uint8Array): Promise<OB11ProfileLikeEvent | undefined> {
|
||||||
const likeTip = decodeProfileLikeTip(Uint8Array.from(wrappedBody));
|
const likeTip = decodeProfileLikeTip(Uint8Array.from(wrappedBody));
|
||||||
if (likeTip?.msgType !== 0 || likeTip?.subType !== 203) return;
|
if (likeTip?.msgType !== 0 || likeTip?.subType !== 203) return;
|
||||||
|
|||||||
@ -265,16 +265,22 @@ export class NapCatOneBot11Adapter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const msgIdSend = new LRUCache<string, number>(100);
|
const msgIdSend = new LRUCache<string, number>(100);
|
||||||
const recallMsgs = new LRUCache<string, boolean>(100);
|
|
||||||
msgListener.onAddSendMsg = async (msg) => {
|
msgListener.onAddSendMsg = async (msg) => {
|
||||||
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SENDING) {
|
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SENDING) {
|
||||||
msgIdSend.put(msg.msgId, 0);
|
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) => {
|
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)) {
|
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) {
|
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && msgIdSend.get(msg.msgId) == 0) {
|
||||||
msgIdSend.put(msg.msgId, 1);
|
msgIdSend.put(msg.msgId, 1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user