mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-18 20:30:08 +08:00
Enhance GrayTip JSON event handling and types
Added the XmlToJsonParam interface and extended the GrayTipElement type to support additional JSON event fields. Updated group API logic to handle busiId as string or number and improved event type checks for robustness.
This commit is contained in:
parent
f4dedf4803
commit
652b5d6118
@ -20,16 +20,16 @@ export interface SendElementBase<ET extends ElementType> {
|
||||
}
|
||||
|
||||
type ElementBase<
|
||||
K extends keyof ElementFullBase,
|
||||
S extends Partial<{ [P in K]: keyof NonNullable<ElementFullBase[P]> | Array<keyof NonNullable<ElementFullBase[P]>> }> = object
|
||||
K extends keyof ElementFullBase,
|
||||
S extends Partial<{ [P in K]: keyof NonNullable<ElementFullBase[P]> | Array<keyof NonNullable<ElementFullBase[P]>> }> = object
|
||||
> = {
|
||||
[P in K]:
|
||||
S[P] extends Array<infer U>
|
||||
[P in K]:
|
||||
S[P] extends Array<infer U>
|
||||
? Pick<NonNullable<ElementFullBase[P]>, U & keyof NonNullable<ElementFullBase[P]>>
|
||||
: S[P] extends keyof NonNullable<ElementFullBase[P]>
|
||||
? Pick<NonNullable<ElementFullBase[P]>, S[P]>
|
||||
: NonNullable<ElementFullBase[P]>;
|
||||
};
|
||||
? Pick<NonNullable<ElementFullBase[P]>, S[P]>
|
||||
: NonNullable<ElementFullBase[P]>;
|
||||
};
|
||||
|
||||
export interface TextElement {
|
||||
content: string;
|
||||
@ -63,6 +63,20 @@ export interface GrayTipRovokeElement {
|
||||
wording: string; // 自定义的撤回提示语
|
||||
}
|
||||
|
||||
export interface XmlToJsonParam {
|
||||
busiType: string;
|
||||
busiId: string;
|
||||
c2cType: number;
|
||||
serviceType: number;
|
||||
ctrlFlag: number;
|
||||
content: string;
|
||||
templId: string;
|
||||
seqId: string;
|
||||
templParam: Map<string, string>;
|
||||
pbReserv: null | string;
|
||||
members: Map<string, string>;
|
||||
}
|
||||
|
||||
export interface GrayTipElement {
|
||||
subElementType: NTGrayTipElementSubTypeV2;
|
||||
revokeElement: GrayTipRovokeElement;
|
||||
@ -74,8 +88,11 @@ export interface GrayTipElement {
|
||||
templId: string;
|
||||
};
|
||||
jsonGrayTipElement: {
|
||||
busiId?: number;
|
||||
busiId?: number | string;
|
||||
jsonStr: string;
|
||||
recentAbstract?: string;
|
||||
isServer?: boolean;
|
||||
xmlToJsonParam?: XmlToJsonParam;
|
||||
};
|
||||
}
|
||||
|
||||
@ -352,7 +369,7 @@ export type SendPicElement = SendElementBase<ElementType.PIC> & ElementBase<'pic
|
||||
|
||||
export type SendPttElement = SendElementBase<ElementType.PTT> & ElementBase<'pttElement', {
|
||||
pttElement: ['fileName', 'filePath', 'md5HexStr', 'fileSize', 'duration', 'formatType', 'voiceType',
|
||||
'voiceChangeType', 'canConvert2Text', 'waveAmplitudes', 'fileSubId', 'playState', 'autoConvertText', 'storeID', 'otherBusinessInfo']
|
||||
'voiceChangeType', 'canConvert2Text', 'waveAmplitudes', 'fileSubId', 'playState', 'autoConvertText', 'storeID', 'otherBusinessInfo'];
|
||||
}>;
|
||||
|
||||
export type SendFileElement = SendElementBase<ElementType.FILE> & ElementBase<'fileElement'>;
|
||||
@ -368,5 +385,5 @@ export type SendShareLocationElement = SendElementBase<ElementType.SHARELOCATION
|
||||
export type SendMultiForwardMsgElement = SendElementBase<ElementType.MULTIFORWARD> & ElementBase<'multiForwardMsgElement'>;
|
||||
|
||||
export type SendMessageElement = SendTextElement | SendPttElement |
|
||||
SendPicElement | SendReplyElement | SendFaceElement | SendMarketFaceElement | SendFileElement |
|
||||
SendVideoElement | SendArkElement | SendMarkdownElement | SendShareLocationElement;
|
||||
SendPicElement | SendReplyElement | SendFaceElement | SendMarketFaceElement | SendFileElement |
|
||||
SendVideoElement | SendArkElement | SendMarkdownElement | SendShareLocationElement;
|
||||
|
||||
@ -350,15 +350,16 @@ export class OneBotGroupApi {
|
||||
// return await this.obContext.apis.GroupApi.parseGroupIncreaseEvent(msg.peerUid, grayTipElement);
|
||||
}
|
||||
} else if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||
// 解析json事件
|
||||
if (grayTipElement.jsonGrayTipElement.busiId === 1061) {
|
||||
// 解析json事件 busiId好像是string类型的?
|
||||
if (grayTipElement.jsonGrayTipElement.busiId?.toString() === '1061') {
|
||||
return await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||
} else if (grayTipElement.jsonGrayTipElement.busiId === JsonGrayBusiId.AIO_GROUP_ESSENCE_MSG_TIP) {
|
||||
return await this.parseEssenceMsg(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||
} else if (+(grayTipElement.jsonGrayTipElement.busiId ?? 0) === 51) {
|
||||
} else if ((grayTipElement.jsonGrayTipElement.busiId ?? 0).toString() === '51') {
|
||||
// 51是什么?{"align":"center","items":[{"txt":"下一秒起床通过王者荣耀加入群","type":"nor"}]
|
||||
return await this.parse51TypeEvent(msg, grayTipElement);
|
||||
} else {
|
||||
console.log('Unknown JSON event:', grayTipElement.jsonGrayTipElement, JSON.stringify(grayTipElement));
|
||||
return await this.parseOtherJsonEvent(msg, grayTipElement.jsonGrayTipElement.jsonStr, this.core.context);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user