mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
功能修改
修改群管变更事件获取渠道,让所有群角色都能收到群管变更通知
This commit is contained in:
parent
8ba47635d3
commit
9f1d4c4db2
@ -318,34 +318,36 @@ function onLoad() {
|
||||
// if (notify.user2.uid) {
|
||||
// member2 = await getGroupMember(notify.group.groupCode, null, notify.user2.uid);
|
||||
// }
|
||||
if (
|
||||
[GroupNotifyTypes.ADMIN_SET, GroupNotifyTypes.ADMIN_UNSET, GroupNotifyTypes.ADMIN_UNSET_OTHER].includes(
|
||||
notify.type,
|
||||
)
|
||||
) {
|
||||
const member1 = await getGroupMember(notify.group.groupCode, notify.user1.uid)
|
||||
log('有管理员变动通知')
|
||||
refreshGroupMembers(notify.group.groupCode).then()
|
||||
let groupAdminNoticeEvent = new OB11GroupAdminNoticeEvent()
|
||||
groupAdminNoticeEvent.group_id = parseInt(notify.group.groupCode)
|
||||
log('开始获取变动的管理员')
|
||||
if (member1) {
|
||||
log('变动管理员获取成功')
|
||||
groupAdminNoticeEvent.user_id = parseInt(member1.uin)
|
||||
groupAdminNoticeEvent.sub_type = [
|
||||
GroupNotifyTypes.ADMIN_UNSET,
|
||||
GroupNotifyTypes.ADMIN_UNSET_OTHER,
|
||||
].includes(notify.type)
|
||||
? 'unset'
|
||||
: 'set'
|
||||
// member1.role = notify.type == GroupNotifyTypes.ADMIN_SET ? GroupMemberRole.admin : GroupMemberRole.normal;
|
||||
postOb11Event(groupAdminNoticeEvent, true)
|
||||
}
|
||||
else {
|
||||
log('获取群通知的成员信息失败', notify, getGroup(notify.group.groupCode))
|
||||
}
|
||||
}
|
||||
else if (notify.type == GroupNotifyTypes.MEMBER_EXIT || notify.type == GroupNotifyTypes.KICK_MEMBER) {
|
||||
// 原本的群管变更通知事件处理
|
||||
// if (
|
||||
// [GroupNotifyTypes.ADMIN_SET, GroupNotifyTypes.ADMIN_UNSET, GroupNotifyTypes.ADMIN_UNSET_OTHER].includes(
|
||||
// notify.type,
|
||||
// )
|
||||
// ) {
|
||||
// const member1 = await getGroupMember(notify.group.groupCode, notify.user1.uid)
|
||||
// log('有管理员变动通知')
|
||||
// refreshGroupMembers(notify.group.groupCode).then()
|
||||
// let groupAdminNoticeEvent = new OB11GroupAdminNoticeEvent()
|
||||
// groupAdminNoticeEvent.group_id = parseInt(notify.group.groupCode)
|
||||
// log('开始获取变动的管理员')
|
||||
// if (member1) {
|
||||
// log('变动管理员获取成功')
|
||||
// groupAdminNoticeEvent.user_id = parseInt(member1.uin)
|
||||
// groupAdminNoticeEvent.sub_type = [
|
||||
// GroupNotifyTypes.ADMIN_UNSET,
|
||||
// GroupNotifyTypes.ADMIN_UNSET_OTHER,
|
||||
// ].includes(notify.type)
|
||||
// ? 'unset'
|
||||
// : 'set'
|
||||
// // member1.role = notify.type == GroupNotifyTypes.ADMIN_SET ? GroupMemberRole.admin : GroupMemberRole.normal;
|
||||
// postOb11Event(groupAdminNoticeEvent, true)
|
||||
// }
|
||||
// else {
|
||||
// log('获取群通知的成员信息失败', notify, getGroup(notify.group.groupCode))
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
if (notify.type == GroupNotifyTypes.MEMBER_EXIT || notify.type == GroupNotifyTypes.KICK_MEMBER) {
|
||||
log('有成员退出通知', notify)
|
||||
try {
|
||||
const member1 = await NTQQUserApi.getUserDetailInfo(notify.user1.uid)
|
||||
|
@ -23,6 +23,7 @@ import { log } from '@/common/utils'
|
||||
import { isNumeric, sleep } from '@/common/utils'
|
||||
import { OB11Constructor } from '../onebot11/constructor'
|
||||
import { OB11GroupCardEvent } from '../onebot11/event/notice/OB11GroupCardEvent'
|
||||
import { OB11GroupAdminNoticeEvent } from '../onebot11/event/notice/OB11GroupAdminNoticeEvent'
|
||||
|
||||
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
||||
|
||||
@ -369,6 +370,13 @@ export async function startHook() {
|
||||
postOb11Event(
|
||||
new OB11GroupCardEvent(parseInt(groupCode), parseInt(member.uin), member.cardName, existMember.cardName),
|
||||
)
|
||||
} else if (member.role != existMember.role) {
|
||||
log('有管理员变动通知')
|
||||
let groupAdminNoticeEvent = new OB11GroupAdminNoticeEvent()
|
||||
groupAdminNoticeEvent.group_id = parseInt(groupCode)
|
||||
groupAdminNoticeEvent.user_id = parseInt(member.uin)
|
||||
groupAdminNoticeEvent.sub_type = member.role == GroupMemberRole.admin ? 'set' : 'unset'
|
||||
postOb11Event(groupAdminNoticeEvent, true)
|
||||
}
|
||||
Object.assign(existMember, member)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user