mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: parseGroupUploadFileEvene
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
ChatType,
|
ChatType,
|
||||||
|
FileElement,
|
||||||
GrayTipElement,
|
GrayTipElement,
|
||||||
InstanceContext,
|
InstanceContext,
|
||||||
JsonGrayBusiId,
|
JsonGrayBusiId,
|
||||||
|
MessageElement,
|
||||||
NapCatCore,
|
NapCatCore,
|
||||||
NTGrayTipElementSubTypeV2,
|
NTGrayTipElementSubTypeV2,
|
||||||
|
NTMsgType,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
TipGroupElement,
|
TipGroupElement,
|
||||||
TipGroupElementType,
|
TipGroupElementType,
|
||||||
@@ -21,6 +24,9 @@ import { OB11GroupPokeEvent } from '@/onebot/event/notice/OB11PokeEvent';
|
|||||||
import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent';
|
import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent';
|
||||||
import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent';
|
import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent';
|
||||||
import { OB11EmitEventContent } from '../network';
|
import { OB11EmitEventContent } from '../network';
|
||||||
|
import { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNoticeEvent';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
|
||||||
export class OneBotGroupApi {
|
export class OneBotGroupApi {
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
@@ -272,42 +278,55 @@ export class OneBotGroupApi {
|
|||||||
// 获取MsgSeq+Peer可获取具体消息
|
// 获取MsgSeq+Peer可获取具体消息
|
||||||
}
|
}
|
||||||
|
|
||||||
// async parseGroupUploadFileEvene() {
|
async parseGroupUploadFileEvene(msg: RawMessage, element: FileElement, elementWrapper: MessageElement) {
|
||||||
// return new OB11GroupUploadNoticeEvent(
|
return new OB11GroupUploadNoticeEvent(
|
||||||
// this.core,
|
this.core,
|
||||||
// parseInt(msg.peerUid), parseInt(msg.senderUin || ''),
|
parseInt(msg.peerUid), parseInt(msg.senderUin || ''),
|
||||||
// {
|
{
|
||||||
// id: FileNapCatOneBotUUID.encode({
|
id: FileNapCatOneBotUUID.encode({
|
||||||
// chatType: ChatType.KCHATTYPEGROUP,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
// peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
// }, msg.msgId, element.elementId, element.fileElement.fileUuid, "." + element.fileElement.fileName),
|
}, msg.msgId, elementWrapper.elementId, elementWrapper?.fileElement?.fileUuid, "." + element.fileName),
|
||||||
// url: pathToFileURL(element.fileElement.filePath).href,
|
url: pathToFileURL(element.filePath).href,
|
||||||
// name: element.fileElement.fileName,
|
name: element.fileName,
|
||||||
// size: parseInt(element.fileElement.fileSize),
|
size: parseInt(element.fileSize),
|
||||||
// busid: element.fileElement.fileBizId ?? 0,
|
busid: element.fileBizId ?? 0,
|
||||||
// },
|
},
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||||
let events: Array<OB11EmitEventContent> = [];
|
let events: Array<OB11EmitEventContent> = [];
|
||||||
|
|
||||||
// 群名片修改事件解析
|
// 群名片修改事件解析 任何都该判断
|
||||||
|
if (msg.senderUin && msg.senderUin !== '0') {
|
||||||
const cardChangedEvent = await this.parseCardChangedEvent(msg);
|
const cardChangedEvent = await this.parseCardChangedEvent(msg);
|
||||||
if (cardChangedEvent) {
|
if (cardChangedEvent) {
|
||||||
events.push(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.groupElement) {
|
|
||||||
const groupEvent = await this.parseGroupElement(msg, grayTipElement.groupElement, grayTipElement);
|
const groupEvent = await this.parseGroupElement(msg, grayTipElement.groupElement, grayTipElement);
|
||||||
if (groupEvent) {
|
if (groupEvent) {
|
||||||
events.push(groupEvent);
|
events.push(groupEvent);
|
||||||
}
|
}
|
||||||
}
|
} else if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
||||||
|
|
||||||
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);
|
const emojiLikeEvent = await this.obContext.apis.GroupApi.parseGroupEmojiLikeEventByGrayTip(msg.peerUid, grayTipElement);
|
||||||
@@ -321,6 +340,7 @@ export class OneBotGroupApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
} else if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||||
|
// 解析json事件
|
||||||
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
const paiYiPaiEvent = await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
const paiYiPaiEvent = await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
if (paiYiPaiEvent) {
|
if (paiYiPaiEvent) {
|
||||||
|
Reference in New Issue
Block a user