mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: event parse
This commit is contained in:
@@ -174,6 +174,7 @@ export class OneBotGroupApi {
|
|||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseCardChangedEvent(msg: RawMessage) {
|
async parseCardChangedEvent(msg: RawMessage) {
|
||||||
if (msg.senderUin && msg.senderUin !== '0') {
|
if (msg.senderUin && msg.senderUin !== '0') {
|
||||||
const member = await this.core.apis.GroupApi.getGroupMember(msg.peerUid, msg.senderUin);
|
const member = await this.core.apis.GroupApi.getGroupMember(msg.peerUid, msg.senderUin);
|
||||||
@@ -296,68 +297,28 @@ export class OneBotGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||||
let events: Array<OB11EmitEventContent> = [];
|
|
||||||
|
|
||||||
// 群名片修改事件解析 任何都该判断
|
|
||||||
if (msg.senderUin && msg.senderUin !== '0') {
|
|
||||||
const cardChangedEvent = await this.parseCardChangedEvent(msg);
|
|
||||||
if (cardChangedEvent) {
|
|
||||||
events.push(cardChangedEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (msg.msgType === NTMsgType.KMSGTYPEFILE) {
|
|
||||||
//文件上传事件 文件为单一元素
|
|
||||||
const elementWrapper = msg.elements.find(e => !!e.fileElement);
|
|
||||||
if (elementWrapper && elementWrapper.fileElement) {
|
|
||||||
const uploadGroupFileEvent = await this.parseGroupUploadFileEvene(msg, elementWrapper.fileElement, elementWrapper);
|
|
||||||
if (uploadGroupFileEvent) {
|
|
||||||
events.push(uploadGroupFileEvent);
|
|
||||||
return events;//带有file 说明必然不可能是灰条消息
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
||||||
// 解析群组事件
|
// 解析群组事件
|
||||||
const groupEvent = await this.parseGroupElement(msg, grayTipElement.groupElement, grayTipElement);
|
return await this.parseGroupElement(msg, grayTipElement.groupElement, grayTipElement);
|
||||||
if (groupEvent) {
|
|
||||||
events.push(groupEvent);
|
|
||||||
}
|
|
||||||
} else if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
} else if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
||||||
// 筛选出表情回应 事件
|
// 筛选出表情回应 事件
|
||||||
if (grayTipElement.xmlElement?.templId === '10382') {
|
if (grayTipElement.xmlElement?.templId === '10382') {
|
||||||
const emojiLikeEvent = await this.obContext.apis.GroupApi.parseGroupEmojiLikeEventByGrayTip(msg.peerUid, grayTipElement);
|
return await this.obContext.apis.GroupApi.parseGroupEmojiLikeEventByGrayTip(msg.peerUid, grayTipElement);
|
||||||
if (emojiLikeEvent) {
|
|
||||||
events.push(emojiLikeEvent);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const GroupIncreaseEvent = await this.obContext.apis.GroupApi.parseGroupIncreaseEvent(msg.peerUid, grayTipElement);
|
return await this.obContext.apis.GroupApi.parseGroupIncreaseEvent(msg.peerUid, grayTipElement);
|
||||||
if (GroupIncreaseEvent) {
|
|
||||||
events.push(GroupIncreaseEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
} else if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||||
// 解析json事件
|
// 解析json事件
|
||||||
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
const paiYiPaiEvent = await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
return await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
if (paiYiPaiEvent) {
|
|
||||||
events.push(paiYiPaiEvent);
|
|
||||||
}
|
|
||||||
} else if (grayTipElement.jsonGrayTipElement.busiId == JsonGrayBusiId.AIO_GROUP_ESSENCE_MSG_TIP) {
|
} else if (grayTipElement.jsonGrayTipElement.busiId == JsonGrayBusiId.AIO_GROUP_ESSENCE_MSG_TIP) {
|
||||||
const essenceMsgEvent = await this.parseEssenceMsg(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
return await this.parseEssenceMsg(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
if (essenceMsgEvent) {
|
|
||||||
events.push(essenceMsgEvent);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const otherJsonEvent = await this.parseOtherJsonEvent(msg, grayTipElement.jsonGrayTipElement.jsonStr, this.core.context)
|
return await this.parseOtherJsonEvent(msg, grayTipElement.jsonGrayTipElement.jsonStr, this.core.context)
|
||||||
if (otherJsonEvent) {
|
|
||||||
events.push(otherJsonEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return events;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ import {
|
|||||||
Peer,
|
Peer,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SendStatusType,
|
SendStatusType,
|
||||||
|
NTMsgType,
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { OB11ConfigLoader } from '@/onebot/config';
|
import { OB11ConfigLoader } from '@/onebot/config';
|
||||||
import {
|
import {
|
||||||
@@ -600,10 +601,24 @@ export class NapCatOneBot11Adapter {
|
|||||||
|
|
||||||
private async handleGroupEvent(message: RawMessage) {
|
private async handleGroupEvent(message: RawMessage) {
|
||||||
try {
|
try {
|
||||||
|
// 群名片修改事件解析 任何都该判断
|
||||||
|
if (message.senderUin && message.senderUin !== '0') {
|
||||||
|
const cardChangedEvent = await this.apis.GroupApi.parseCardChangedEvent(message);
|
||||||
|
cardChangedEvent && await this.networkManager.emitEvent(cardChangedEvent);
|
||||||
|
}
|
||||||
|
if (message.msgType === NTMsgType.KMSGTYPEFILE) {
|
||||||
|
//文件上传事件 文件为单一元素
|
||||||
|
const elementWrapper = message.elements.find(e => !!e.fileElement);
|
||||||
|
if (elementWrapper?.fileElement) {
|
||||||
|
const uploadGroupFileEvent = await this.apis.GroupApi.parseGroupUploadFileEvene(message, elementWrapper.fileElement, elementWrapper);
|
||||||
|
uploadGroupFileEvent && await this.networkManager.emitEvent(uploadGroupFileEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
const grayTipElement = message.elements.find((element) => element.grayTipElement)?.grayTipElement;
|
const grayTipElement = message.elements.find((element) => element.grayTipElement)?.grayTipElement;
|
||||||
if (!grayTipElement) return;
|
if (grayTipElement) {
|
||||||
const events = await this.apis.GroupApi.parseGrayTipElement(message, grayTipElement);
|
const event = await this.apis.GroupApi.parseGrayTipElement(message, grayTipElement);
|
||||||
await this.networkManager.emitEvents(events);
|
event && await this.networkManager.emitEvent(event);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.context.logger.logError('constructGroupEvent error: ', e);
|
this.context.logger.logError('constructGroupEvent error: ', e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user