mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: 进群入群
This commit is contained in:
@@ -56,6 +56,7 @@ export interface GrayTipElement {
|
|||||||
aioOpGrayTipElement: TipAioOpGrayTipElement;
|
aioOpGrayTipElement: TipAioOpGrayTipElement;
|
||||||
groupElement: TipGroupElement;
|
groupElement: TipGroupElement;
|
||||||
xmlElement: {
|
xmlElement: {
|
||||||
|
busiId: string;
|
||||||
content: string;
|
content: string;
|
||||||
templId: string;
|
templId: string;
|
||||||
};
|
};
|
||||||
|
@@ -24,6 +24,7 @@ import { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNotic
|
|||||||
import { OB11GroupNameEvent } from '../event/notice/OB11GroupNameEvent';
|
import { OB11GroupNameEvent } from '../event/notice/OB11GroupNameEvent';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
import { OB11GroupIncreaseEvent } from '../event/notice/OB11GroupIncreaseEvent';
|
||||||
|
|
||||||
export class OneBotGroupApi {
|
export class OneBotGroupApi {
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
@@ -219,16 +220,51 @@ export class OneBotGroupApi {
|
|||||||
} else if (element.type === TipGroupElementType.KSHUTUP) {
|
} else if (element.type === TipGroupElementType.KSHUTUP) {
|
||||||
let event = await this.parseGroupBanEvent(msg.peerUid, elementWrapper);
|
let event = await this.parseGroupBanEvent(msg.peerUid, elementWrapper);
|
||||||
return event;
|
return event;
|
||||||
|
} else if (element.type === TipGroupElementType.KMEMBERADD) {
|
||||||
|
// 自己的通知 协议推送为type->85 在这里实现为了避免邀请出现问题
|
||||||
|
if (element.memberUid == this.core.selfInfo.uid) {
|
||||||
|
this.core.apis.GroupApi.refreshGroupMemberCache(msg.peerUid).then().catch();
|
||||||
|
return new OB11GroupIncreaseEvent(
|
||||||
|
this.core,
|
||||||
|
parseInt(msg.peerUid),
|
||||||
|
+this.core.selfInfo.uin,
|
||||||
|
element.adminUid ? +await this.core.apis.UserApi.getUinByUidV2(element.adminUid) : 0,
|
||||||
|
'approve'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async parseSelfInviteEvent(msg: RawMessage, inviterUin: string, inviteeUin: string) {
|
||||||
|
return new OB11GroupIncreaseEvent(
|
||||||
|
this.core,
|
||||||
|
parseInt(msg.peerUid),
|
||||||
|
+inviteeUin,
|
||||||
|
+inviterUin,
|
||||||
|
'invite'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||||
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
||||||
// 解析群组事件 由sysmsg解析
|
// 解析群组事件 由sysmsg解析
|
||||||
return await this.parseGroupElement(msg, grayTipElement.groupElement, grayTipElement);
|
return await this.parseGroupElement(msg, grayTipElement.groupElement, grayTipElement);
|
||||||
} 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.busiId === '10145') {
|
||||||
|
// const inviteData = new fastXmlParser.XMLParser({
|
||||||
|
// ignoreAttributes: false,
|
||||||
|
// attributeNamePrefix: '',
|
||||||
|
// }).parse(grayTipElement.xmlElement.content);
|
||||||
|
|
||||||
|
// const inviterUin: string = inviteData.gtip.qq[0].jp;
|
||||||
|
// const inviteeUin: string = inviteData.gtip.qq[1].jp;
|
||||||
|
// //刷新群缓存
|
||||||
|
// if (inviteeUin === this.core.selfInfo.uin) {
|
||||||
|
// this.core.apis.GroupApi.refreshGroupMemberCache(msg.peerUid).then().catch();
|
||||||
|
// return this.parseSelfInviteEvent(msg, inviterUin, inviteeUin);
|
||||||
|
// }
|
||||||
|
} else if (grayTipElement.xmlElement?.templId === '10382') {
|
||||||
return await this.obContext.apis.GroupApi.parseGroupEmojiLikeEventByGrayTip(msg.peerUid, grayTipElement);
|
return await this.obContext.apis.GroupApi.parseGroupEmojiLikeEventByGrayTip(msg.peerUid, grayTipElement);
|
||||||
} else {
|
} else {
|
||||||
//return await this.obContext.apis.GroupApi.parseGroupIncreaseEvent(msg.peerUid, grayTipElement);
|
//return await this.obContext.apis.GroupApi.parseGroupIncreaseEvent(msg.peerUid, grayTipElement);
|
||||||
|
@@ -1012,16 +1012,8 @@ export class OneBotMsgApi {
|
|||||||
|
|
||||||
async parseSysMessage(msg: number[]) {
|
async parseSysMessage(msg: number[]) {
|
||||||
const SysMessage = new NapProtoMsg(PushMsgBody).decode(Uint8Array.from(msg));
|
const SysMessage = new NapProtoMsg(PushMsgBody).decode(Uint8Array.from(msg));
|
||||||
if (SysMessage.contentHead.type == 85 && SysMessage.body?.msgContent) {
|
// 邀请需要解grayTipElement
|
||||||
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
if (SysMessage.contentHead.type == 33 && SysMessage.body?.msgContent) {
|
||||||
return new OB11GroupIncreaseEvent(
|
|
||||||
this.core,
|
|
||||||
groupChange.groupUin,
|
|
||||||
+this.core.selfInfo.uin,
|
|
||||||
groupChange.memberUid ? +await this.core.apis.UserApi.getUinByUidV2(groupChange.memberUid) : 0,
|
|
||||||
'approve'
|
|
||||||
);
|
|
||||||
} else if (SysMessage.contentHead.type == 33 && SysMessage.body?.msgContent) {
|
|
||||||
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
||||||
this.core.apis.GroupApi.refreshGroupMemberCache(groupChange.groupUin.toString()).then().catch();
|
this.core.apis.GroupApi.refreshGroupMemberCache(groupChange.groupUin.toString()).then().catch();
|
||||||
let operatorUid = await this.waitGroupNotify(
|
let operatorUid = await this.waitGroupNotify(
|
||||||
|
Reference in New Issue
Block a user