mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: parsePrivateMsgEvent
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
|||||||
SendTextElement,
|
SendTextElement,
|
||||||
BaseEmojiType,
|
BaseEmojiType,
|
||||||
FaceType,
|
FaceType,
|
||||||
|
GrayTipElement,
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import faceConfig from '@/core/external/face_config.json';
|
import faceConfig from '@/core/external/face_config.json';
|
||||||
import { NapCatOneBot11Adapter, OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageFileBase, OB11MessageForward, } from '@/onebot';
|
import { NapCatOneBot11Adapter, OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageFileBase, OB11MessageForward, } from '@/onebot';
|
||||||
@@ -664,20 +665,13 @@ export class OneBotMsgApi {
|
|||||||
this.core = core;
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parsePrivateMsgEvent(msg: RawMessage) {
|
async parsePrivateMsgEvent(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||||
if (msg.chatType !== ChatType.KCHATTYPEC2C) {
|
if (grayTipElement && grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||||
return;
|
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
}
|
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement);
|
||||||
for (const element of msg.elements) {
|
if (PokeEvent) return PokeEvent;
|
||||||
if (element.grayTipElement && element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
} else if (grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') {
|
||||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));
|
||||||
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(element.grayTipElement);
|
|
||||||
if (PokeEvent) return PokeEvent;
|
|
||||||
}
|
|
||||||
//好友添加成功事件
|
|
||||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') {
|
|
||||||
return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -626,14 +626,19 @@ export class NapCatOneBot11Adapter {
|
|||||||
|
|
||||||
private async handlePrivateMsgEvent(message: RawMessage) {
|
private async handlePrivateMsgEvent(message: RawMessage) {
|
||||||
try {
|
try {
|
||||||
const privateEvent = await this.apis.MsgApi.parsePrivateMsgEvent(message);
|
if (message.msgType === NTMsgType.KMSGTYPEGRAYTIPS) {
|
||||||
if (privateEvent) {
|
// 灰条为单元素消息
|
||||||
this.networkManager.emitEvent(privateEvent);
|
const grayTipElement = message.elements[0].grayTipElement;
|
||||||
|
if (grayTipElement) {
|
||||||
|
const event = await this.apis.MsgApi.parsePrivateMsgEvent(message, grayTipElement);
|
||||||
|
event && await this.networkManager.emitEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.context.logger.logError('constructPrivateEvent error: ', e);
|
this.context.logger.logError('constructPrivateEvent error: ', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async emitRecallMsg(msgList: RawMessage[], cache: LRUCache<string, boolean>) {
|
private async emitRecallMsg(msgList: RawMessage[], cache: LRUCache<string, boolean>) {
|
||||||
for (const message of msgList) {
|
for (const message of msgList) {
|
||||||
// log("message update", message.sendStatus, message.msgId, message.msgSeq)
|
// log("message update", message.sendStatus, message.msgId, message.msgSeq)
|
||||||
|
Reference in New Issue
Block a user