mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: GroupChange
This commit is contained in:
@@ -54,6 +54,16 @@ export const PushMsg = {
|
|||||||
generalFlag: ProtoField(9, ScalarType.INT32, true),
|
generalFlag: ProtoField(9, ScalarType.INT32, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const GroupChange = {
|
||||||
|
groupUin: ProtoField(1, ScalarType.UINT32),
|
||||||
|
flag: ProtoField(2, ScalarType.UINT32),
|
||||||
|
memberUid: ProtoField(3, ScalarType.STRING, true),
|
||||||
|
decreaseType: ProtoField(4, ScalarType.UINT32),
|
||||||
|
operatorUid: ProtoField(5, ScalarType.STRING, true),
|
||||||
|
increaseType: ProtoField(6, ScalarType.UINT32),
|
||||||
|
field7: ProtoField(7, ScalarType.BYTES, true),
|
||||||
|
}
|
||||||
|
|
||||||
export const PushMsgBody = {
|
export const PushMsgBody = {
|
||||||
responseHead: ProtoField(1, () => ResponseHead),
|
responseHead: ProtoField(1, () => ResponseHead),
|
||||||
contentHead: ProtoField(2, () => ContentHead),
|
contentHead: ProtoField(2, () => ContentHead),
|
||||||
|
@@ -23,7 +23,6 @@ import { OB11GroupCardEvent } from '@/onebot/event/notice/OB11GroupCardEvent';
|
|||||||
import { OB11GroupPokeEvent } from '@/onebot/event/notice/OB11PokeEvent';
|
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 { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNoticeEvent';
|
import { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNoticeEvent';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
@@ -93,40 +92,40 @@ export class OneBotGroupApi {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
// async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||||
const groupElement = grayTipElement?.groupElement;
|
// const groupElement = grayTipElement?.groupElement;
|
||||||
if (!groupElement) return undefined;
|
// if (!groupElement) return undefined;
|
||||||
const member = await this.core.apis.UserApi.getUserDetailInfo(groupElement.memberUid);
|
// const member = await this.core.apis.UserApi.getUserDetailInfo(groupElement.memberUid);
|
||||||
const memberUin = member?.uin;
|
// const memberUin = member?.uin;
|
||||||
const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
// const adminMember = await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid);
|
||||||
if (memberUin) {
|
// if (memberUin) {
|
||||||
const operatorUin = adminMember?.uin ?? memberUin;
|
// const operatorUin = adminMember?.uin ?? memberUin;
|
||||||
return new OB11GroupIncreaseEvent(
|
// return new OB11GroupIncreaseEvent(
|
||||||
this.core,
|
// this.core,
|
||||||
parseInt(GroupCode),
|
// parseInt(GroupCode),
|
||||||
parseInt(memberUin),
|
// parseInt(memberUin),
|
||||||
parseInt(operatorUin),
|
// parseInt(operatorUin),
|
||||||
);
|
// );
|
||||||
} else {
|
// } else {
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
// async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||||
const groupElement = grayTipElement?.groupElement;
|
// const groupElement = grayTipElement?.groupElement;
|
||||||
if (!groupElement) return undefined;
|
// if (!groupElement) return undefined;
|
||||||
const adminUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin ?? (await this.core.apis.UserApi.getUidByUinV2(groupElement.adminUid));
|
// const adminUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, groupElement.adminUid))?.uin ?? (await this.core.apis.UserApi.getUidByUinV2(groupElement.adminUid));
|
||||||
if (adminUin) {
|
// if (adminUin) {
|
||||||
return new OB11GroupDecreaseEvent(
|
// return new OB11GroupDecreaseEvent(
|
||||||
this.core,
|
// this.core,
|
||||||
parseInt(GroupCode),
|
// parseInt(GroupCode),
|
||||||
parseInt(this.core.selfInfo.uin),
|
// parseInt(this.core.selfInfo.uin),
|
||||||
parseInt(adminUin),
|
// parseInt(adminUin),
|
||||||
'kick_me',
|
// 'kick_me',
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async parseGroupEmojiLikeEventByGrayTip(
|
async parseGroupEmojiLikeEventByGrayTip(
|
||||||
groupCode: string,
|
groupCode: string,
|
||||||
@@ -188,30 +187,30 @@ export class OneBotGroupApi {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseGroupElement(msg: RawMessage, groupElement: TipGroupElement, elementWrapper: GrayTipElement) {
|
// async parseGroupElement(msg: RawMessage, groupElement: TipGroupElement, elementWrapper: GrayTipElement) {
|
||||||
if (groupElement.type == TipGroupElementType.KMEMBERADD) {
|
// if (groupElement.type == TipGroupElementType.KMEMBERADD) {
|
||||||
const MemberIncreaseEvent = await this.obContext.apis.GroupApi.parseGroupMemberIncreaseEvent(msg.peerUid, elementWrapper);
|
// const MemberIncreaseEvent = await this.obContext.apis.GroupApi.parseGroupMemberIncreaseEvent(msg.peerUid, elementWrapper);
|
||||||
if (MemberIncreaseEvent) return MemberIncreaseEvent;
|
// if (MemberIncreaseEvent) return MemberIncreaseEvent;
|
||||||
} else if (groupElement.type === TipGroupElementType.KSHUTUP) {
|
// } else if (groupElement.type === TipGroupElementType.KSHUTUP) {
|
||||||
const BanEvent = await this.obContext.apis.GroupApi.parseGroupBanEvent(msg.peerUid, elementWrapper);
|
// const BanEvent = await this.obContext.apis.GroupApi.parseGroupBanEvent(msg.peerUid, elementWrapper);
|
||||||
if (BanEvent) return BanEvent;
|
// if (BanEvent) return BanEvent;
|
||||||
} else if (groupElement.type == TipGroupElementType.KQUITTE) {
|
// } else if (groupElement.type == TipGroupElementType.KQUITTE) {
|
||||||
this.core.apis.GroupApi.quitGroup(msg.peerUid).then();
|
// this.core.apis.GroupApi.quitGroup(msg.peerUid).then();
|
||||||
try {
|
// try {
|
||||||
const KickEvent = await this.obContext.apis.GroupApi.parseGroupKickEvent(msg.peerUid, elementWrapper);
|
// const KickEvent = await this.obContext.apis.GroupApi.parseGroupKickEvent(msg.peerUid, elementWrapper);
|
||||||
if (KickEvent) return KickEvent;
|
// if (KickEvent) return KickEvent;
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
return new OB11GroupDecreaseEvent(
|
// return new OB11GroupDecreaseEvent(
|
||||||
this.core,
|
// this.core,
|
||||||
parseInt(msg.peerUid),
|
// parseInt(msg.peerUid),
|
||||||
parseInt(this.core.selfInfo.uin),
|
// parseInt(this.core.selfInfo.uin),
|
||||||
0,
|
// 0,
|
||||||
'leave',
|
// 'leave',
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async parsePaiYiPai(msg: RawMessage, jsonStr: string) {
|
async parsePaiYiPai(msg: RawMessage, jsonStr: string) {
|
||||||
const json = JSON.parse(jsonStr);
|
const json = JSON.parse(jsonStr);
|
||||||
@@ -298,8 +297,8 @@ export class OneBotGroupApi {
|
|||||||
|
|
||||||
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解析
|
||||||
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) {
|
||||||
// 筛选出表情回应 事件
|
// 筛选出表情回应 事件
|
||||||
|
@@ -32,6 +32,10 @@ import { OB11FriendAddNoticeEvent } from '@/onebot/event/notice/OB11FriendAddNot
|
|||||||
// import { decodeSysMessage } from '@/core/packet/proto/old/ProfileLike';
|
// import { decodeSysMessage } from '@/core/packet/proto/old/ProfileLike';
|
||||||
import { ForwardMsgBuilder } from "@/common/forward-msg-builder";
|
import { ForwardMsgBuilder } from "@/common/forward-msg-builder";
|
||||||
import { decodeSysMessage } from "@/core/helper/adaptDecoder";
|
import { decodeSysMessage } from "@/core/helper/adaptDecoder";
|
||||||
|
import { GroupChange, PushMsgBody } from "@/core/packet/transformer/proto";
|
||||||
|
import { NapProtoMsg } from '@napneko/nap-proto-core';
|
||||||
|
import { OB11GroupIncreaseEvent } from '../event/notice/OB11GroupIncreaseEvent';
|
||||||
|
import { OB11GroupDecreaseEvent, GroupDecreaseSubType } from '../event/notice/OB11GroupDecreaseEvent';
|
||||||
|
|
||||||
type RawToOb11Converters = {
|
type RawToOb11Converters = {
|
||||||
[Key in keyof MessageElement as Key extends `${string}Element` ? Key : never]: (
|
[Key in keyof MessageElement as Key extends `${string}Element` ? Key : never]: (
|
||||||
@@ -953,6 +957,18 @@ export class OneBotMsgApi {
|
|||||||
|
|
||||||
return { path, fileName: inputdata.name ?? fileName };
|
return { path, fileName: inputdata.name ?? fileName };
|
||||||
}
|
}
|
||||||
|
groupChangDecreseType2String(type: number): GroupDecreaseSubType {
|
||||||
|
switch (type) {
|
||||||
|
case 130:
|
||||||
|
return 'kick';
|
||||||
|
case 131:
|
||||||
|
return 'leave';
|
||||||
|
case 3:
|
||||||
|
return 'kick_me';
|
||||||
|
default:
|
||||||
|
return 'kick';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async parseSysMessage(msg: number[]) {
|
async parseSysMessage(msg: number[]) {
|
||||||
const sysMsg = decodeSysMessage(Uint8Array.from(msg));
|
const sysMsg = decodeSysMessage(Uint8Array.from(msg));
|
||||||
@@ -964,6 +980,28 @@ export class OneBotMsgApi {
|
|||||||
if (!sysMsg.bodyWrapper) return;
|
if (!sysMsg.bodyWrapper) return;
|
||||||
return await this.obContext.apis.UserApi.parseLikeEvent(sysMsg.bodyWrapper.wrappedBody);
|
return await this.obContext.apis.UserApi.parseLikeEvent(sysMsg.bodyWrapper.wrappedBody);
|
||||||
}
|
}
|
||||||
|
let SysMessage = new NapProtoMsg(PushMsgBody).decode(Uint8Array.from(msg));
|
||||||
|
if (SysMessage.contentHead.type == 33 && SysMessage.body?.msgContent) {
|
||||||
|
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
||||||
|
console.log(JSON.stringify(groupChange));
|
||||||
|
return new OB11GroupIncreaseEvent(
|
||||||
|
this.core,
|
||||||
|
groupChange.groupUin,
|
||||||
|
groupChange.memberUid ? +await this.core.apis.UserApi.getUinByUidV2(groupChange.memberUid) : 0,
|
||||||
|
groupChange.operatorUid ? +await this.core.apis.UserApi.getUinByUidV2(groupChange.operatorUid) : 0,
|
||||||
|
groupChange.decreaseType == 131 ? 'invite' : 'approve',
|
||||||
|
);
|
||||||
|
} else if (SysMessage.contentHead.type == 34 && SysMessage.body?.msgContent) {
|
||||||
|
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
||||||
|
// console.log(JSON.stringify(groupChange),JSON.stringify(SysMessage));
|
||||||
|
return new OB11GroupDecreaseEvent(
|
||||||
|
this.core,
|
||||||
|
groupChange.groupUin,
|
||||||
|
+this.core.selfInfo.uin,
|
||||||
|
groupChange.operatorUid ? +await this.core.apis.UserApi.getUinByUidV2(groupChange.operatorUid) : 0,
|
||||||
|
this.groupChangDecreseType2String(groupChange.decreaseType),
|
||||||
|
);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (msgType === 732 && subType === 16 && subSubType === 16) {
|
if (msgType === 732 && subType === 16 && subSubType === 16) {
|
||||||
const greyTip = GreyTipWrapper.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody.slice(7)));
|
const greyTip = GreyTipWrapper.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody.slice(7)));
|
||||||
|
@@ -42,7 +42,7 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { proxiedListenerOf } from '@/common/proxy-handler';
|
import { proxiedListenerOf } from '@/common/proxy-handler';
|
||||||
import { OB11FriendRequestEvent } from '@/onebot/event/request/OB11FriendRequest';
|
import { OB11FriendRequestEvent } from '@/onebot/event/request/OB11FriendRequest';
|
||||||
import { OB11GroupAdminNoticeEvent } from '@/onebot/event/notice/OB11GroupAdminNoticeEvent';
|
import { OB11GroupAdminNoticeEvent } from '@/onebot/event/notice/OB11GroupAdminNoticeEvent';
|
||||||
import { GroupDecreaseSubType, OB11GroupDecreaseEvent } from '@/onebot/event/notice/OB11GroupDecreaseEvent';
|
// import { GroupDecreaseSubType, OB11GroupDecreaseEvent } from '@/onebot/event/notice/OB11GroupDecreaseEvent';
|
||||||
import { OB11GroupRequestEvent } from '@/onebot/event/request/OB11GroupRequest';
|
import { OB11GroupRequestEvent } from '@/onebot/event/request/OB11GroupRequest';
|
||||||
import { OB11FriendRecallNoticeEvent } from '@/onebot/event/notice/OB11FriendRecallNoticeEvent';
|
import { OB11FriendRecallNoticeEvent } from '@/onebot/event/notice/OB11FriendRecallNoticeEvent';
|
||||||
import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecallNoticeEvent';
|
import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecallNoticeEvent';
|
||||||
@@ -406,36 +406,38 @@ export class NapCatOneBot11Adapter {
|
|||||||
this.core.apis.GroupApi.getGroup(notify.group.groupCode)
|
this.core.apis.GroupApi.getGroup(notify.group.groupCode)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (
|
} else
|
||||||
notify.type == GroupNotifyMsgType.MEMBER_LEAVE_NOTIFY_ADMIN ||
|
// if (
|
||||||
notify.type == GroupNotifyMsgType.KICK_MEMBER_NOTIFY_ADMIN
|
// notify.type == GroupNotifyMsgType.MEMBER_LEAVE_NOTIFY_ADMIN ||
|
||||||
) {
|
// notify.type == GroupNotifyMsgType.KICK_MEMBER_NOTIFY_ADMIN
|
||||||
this.context.logger.logDebug('有成员退出通知', notify);
|
// ) {
|
||||||
const member1Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
// this.context.logger.logDebug('有成员退出通知', notify);
|
||||||
let operatorId = member1Uin;
|
// const member1Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid);
|
||||||
let subType: GroupDecreaseSubType = 'leave';
|
// let operatorId = member1Uin;
|
||||||
if (notify.user2.uid) {
|
// let subType: GroupDecreaseSubType = 'leave';
|
||||||
// 是被踢的
|
// if (notify.user2.uid) {
|
||||||
const member2Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid);
|
// // 是被踢的
|
||||||
if (member2Uin) {
|
// const member2Uin = await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid);
|
||||||
operatorId = member2Uin;
|
// if (member2Uin) {
|
||||||
}
|
// operatorId = member2Uin;
|
||||||
subType = 'kick';
|
// }
|
||||||
}
|
// subType = 'kick';
|
||||||
const groupDecreaseEvent = new OB11GroupDecreaseEvent(
|
// }
|
||||||
this.core,
|
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(
|
||||||
parseInt(notify.group.groupCode),
|
// this.core,
|
||||||
parseInt(member1Uin),
|
// parseInt(notify.group.groupCode),
|
||||||
parseInt(operatorId),
|
// parseInt(member1Uin),
|
||||||
subType
|
// parseInt(operatorId),
|
||||||
);
|
// subType
|
||||||
this.networkManager
|
// );
|
||||||
.emitEvent(groupDecreaseEvent)
|
// this.networkManager
|
||||||
.catch((e) =>
|
// .emitEvent(groupDecreaseEvent)
|
||||||
this.context.logger.logError.bind(this.context.logger)('处理群成员退出失败', e)
|
// .catch((e) =>
|
||||||
);
|
// this.context.logger.logError.bind(this.context.logger)('处理群成员退出失败', e)
|
||||||
// notify.status == 1 表示未处理 2表示处理完成
|
// );
|
||||||
} else if (
|
// // notify.status == 1 表示未处理 2表示处理完成
|
||||||
|
// } else
|
||||||
|
if (
|
||||||
[GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS].includes(notify.type) &&
|
[GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS].includes(notify.type) &&
|
||||||
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
notify.status == GroupNotifyMsgStatus.KUNHANDLE
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user