Skip to content

Commit ce1ac01

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 9ff1259 + b0c1f47 commit ce1ac01

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

doc/更新日志.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ V6.4.0
88
* 修复 `get_forward_msg` 报错 #633
99
* 修复首次启用 Satori 时,事件不会上报
1010
* 修复系统代理会导致 API 无法调用
11+
* 修复非群管理员无法获取群成员被踢事件
1112
* 支持 `get_stranger_info` 获取 `login_days`
1213
* 支持 40768
1314
* 支持 macOS

src/onebot11/adapter.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,7 @@ class OneBot11Adapter extends Service {
103103
private async handleGroupNotify(notify: GroupNotify, doubt: boolean) {
104104
try {
105105
const flag = `${notify.group.groupCode}|${notify.seq}|${notify.type}|${doubt ? '1' : '0'}`
106-
if ([GroupNotifyType.MemberLeaveNotifyAdmin, GroupNotifyType.KickMemberNotifyAdmin].includes(notify.type)) {
107-
if (notify.user2.uid) {
108-
this.ctx.logger.info('有群成员被踢', notify.group.groupCode, notify.user1.uid, notify.user2.uid)
109-
const memberUin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
110-
const adminUin = await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)
111-
const event = new OB11GroupDecreaseEvent(
112-
parseInt(notify.group.groupCode),
113-
parseInt(memberUin),
114-
parseInt(adminUin),
115-
'kick',
116-
)
117-
this.dispatch(event)
118-
}
119-
}
120-
else if (notify.type === GroupNotifyType.RequestJoinNeedAdminiStratorPass && notify.status === GroupNotifyStatus.Unhandle) {
106+
if (notify.type === GroupNotifyType.RequestJoinNeedAdminiStratorPass && notify.status === GroupNotifyStatus.Unhandle) {
121107
this.ctx.logger.info('有加群请求')
122108
const requestUin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
123109
const event = new OB11GroupRequestEvent(
@@ -317,7 +303,7 @@ class OneBot11Adapter extends Service {
317303
if (input.senderUid === selfInfo.uid) {
318304
this.handleMsg(input, true, false)
319305
}
320-
else{
306+
else {
321307
this.handleMsg(input, false, false)
322308
}
323309
})
@@ -364,12 +350,20 @@ class OneBot11Adapter extends Service {
364350
}
365351
else if (msgType === 34) {
366352
const tip = SysMsg.GroupMemberChange.decode(sysMsg.body!.msgContent!)
367-
if (tip.type !== 130) return // adminUid: 0
368-
this.ctx.logger.info('群成员减少', tip)
369-
const memberUin = await this.ctx.ntUserApi.getUinByUid(tip.memberUid)
370-
const userId = Number(memberUin)
371-
const event = new OB11GroupDecreaseEvent(tip.groupCode, userId, userId)
372-
this.dispatch(event)
353+
if (tip.type === 130) {
354+
this.ctx.logger.info('群成员减少', tip)
355+
const memberUin = await this.ctx.ntUserApi.getUinByUid(tip.memberUid)
356+
const userId = Number(memberUin)
357+
const event = new OB11GroupDecreaseEvent(tip.groupCode, userId, userId)
358+
this.dispatch(event)
359+
} else if (tip.type === 131) {
360+
if (tip.memberUid === selfInfo.uid) return
361+
this.ctx.logger.info('有群成员被踢', tip)
362+
const memberUin = await this.ctx.ntUserApi.getUinByUid(tip.memberUid)
363+
const adminUin = await this.ctx.ntUserApi.getUinByUid(tip.adminUid.match(/\x18([^\x18\x10]+)\x10/)![1])
364+
const event = new OB11GroupDecreaseEvent(tip.groupCode, +memberUin, +adminUin, 'kick')
365+
this.dispatch(event)
366+
}
373367
}
374368
else if (msgType === 528 && subType === 321) {
375369
// 私聊撤回戳一戳,不再从这里解析,应从 nt/message-deleted 事件中解析

0 commit comments

Comments
 (0)