mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: bot join group event
This commit is contained in:
parent
b55f35549d
commit
c7b6fd89fd
@ -244,8 +244,8 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
|
||||
}
|
||||
|
||||
for (const member of oldMembers) {
|
||||
if (!newMembersSet.has(member.uin)) {
|
||||
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin)));
|
||||
if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
||||
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), "leave"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -263,6 +263,8 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
|
||||
|
||||
// 群列表变动
|
||||
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS, (payload) => {
|
||||
// updateType 3是群列表变动,2是群成员变动
|
||||
log("群列表变动", payload.updateType, payload.groupList)
|
||||
if (payload.updateType != 2) {
|
||||
updateGroups(payload.groupList).then();
|
||||
} else {
|
||||
@ -272,6 +274,8 @@ registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROU
|
||||
}
|
||||
})
|
||||
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmdS.GROUPS_STORE, (payload) => {
|
||||
// updateType 3是群列表变动,2是群成员变动
|
||||
log("群列表变动", payload.updateType, payload.groupList)
|
||||
if (payload.updateType != 2) {
|
||||
updateGroups(payload.groupList).then();
|
||||
} else {
|
||||
|
@ -315,6 +315,7 @@ export interface TipAioOpGrayTipElement { // 这是什么提示来着?
|
||||
|
||||
export enum TipGroupElementType {
|
||||
memberIncrease = 1,
|
||||
kicked = 3, // 被移出群
|
||||
ban = 8
|
||||
}
|
||||
|
||||
@ -325,7 +326,7 @@ export interface TipGroupElement {
|
||||
"memberUid": string,
|
||||
"memberNick": string,
|
||||
"memberRemark": string,
|
||||
"adminUid": string, // 同意加群的管理员uid
|
||||
"adminUid": string,
|
||||
"adminNick": string,
|
||||
"adminRemark": string,
|
||||
"createGroup": null,
|
||||
|
@ -19,7 +19,8 @@ import {
|
||||
SelfInfo,
|
||||
Sex,
|
||||
TipGroupElementType,
|
||||
User, VideoElement
|
||||
User,
|
||||
VideoElement
|
||||
} from '../ntqqapi/types';
|
||||
import {getFriend, getGroupMember, selfInfo, tempGroupCodeMap} from '../common/data';
|
||||
import {EventType} from "./event/OB11BaseEvent";
|
||||
@ -37,6 +38,7 @@ import {sleep} from "../common/utils/helper";
|
||||
import {getConfigUtil} from "../common/config";
|
||||
import {OB11GroupTitleEvent} from "./event/notice/OB11GroupTitleEvent";
|
||||
import {OB11GroupCardEvent} from "./event/notice/OB11GroupCardEvent";
|
||||
import {OB11GroupDecreaseEvent} from "./event/notice/OB11GroupDecreaseEvent";
|
||||
|
||||
|
||||
export class OB11Constructor {
|
||||
@ -281,6 +283,13 @@ export class OB11Constructor {
|
||||
return new OB11GroupBanEvent(parseInt(msg.peerUid), parseInt(memberUin), parseInt(adminUin), duration, sub_type);
|
||||
}
|
||||
}
|
||||
else if (groupElement.type == TipGroupElementType.kicked){
|
||||
log("收到我被踢出提示", groupElement)
|
||||
const adminUin = (await getGroupMember(msg.peerUid, groupElement.adminUid))?.uin || (await NTQQUserApi.getUserDetailInfo(groupElement.adminUid))?.uin
|
||||
if (adminUin) {
|
||||
return new OB11GroupDecreaseEvent(parseInt(msg.peerUid), parseInt(selfInfo.uin), parseInt(adminUin), "kick_me");
|
||||
}
|
||||
}
|
||||
} else if (element.fileElement) {
|
||||
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {
|
||||
id: element.fileElement.fileUuid,
|
||||
@ -303,6 +312,7 @@ export class OB11Constructor {
|
||||
while ((match = regex.exec(xmlElement.content)) !== null) {
|
||||
matches.push(match[1]);
|
||||
}
|
||||
// log("新人进群匹配到的QQ号", matches)
|
||||
if (matches.length === 2) {
|
||||
const [inviter, invitee] = matches;
|
||||
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(invitee), parseInt(inviter), "invite");
|
||||
|
@ -1,14 +1,17 @@
|
||||
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
|
||||
|
||||
export type GroupDecreaseSubType = "leave" | "kick" | "kick_me";
|
||||
|
||||
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = "group_decrease";
|
||||
sub_type: "leave" | "kick" | "kick_me" = "leave"; // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
|
||||
sub_type: GroupDecreaseSubType = "leave"; // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
|
||||
operator_id: number;
|
||||
|
||||
constructor(groupId: number, userId: number) {
|
||||
constructor(groupId: number, userId: number, operatorId: number, subType: GroupDecreaseSubType = "leave") {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.operator_id = userId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
|
||||
this.operator_id = operatorId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
|
||||
this.user_id = userId;
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ export function postOB11Event(msg: PostEventType, reportSelf = false) {
|
||||
const config = getConfigUtil().getConfig();
|
||||
// 判断msg是否是event
|
||||
if (!config.reportSelfMessage && !reportSelf) {
|
||||
if ((msg as OB11Message).user_id.toString() == selfInfo.uin) {
|
||||
if (msg.post_type === "message" && (msg as OB11Message).user_id.toString() == selfInfo.uin) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user