Skip to content

Commit

Permalink
修复机器人无权限时不会报告违规消息的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
asforest committed Mar 29, 2023
1 parent 7b1b82b commit 5b959dc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/kotlin/AutoMutePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ object AutoMutePlugin : KotlinPlugin(Env.pluginDescription)
MainCommand.register()

GlobalEventChannel.filter { it is BotEvent }.subscribeAlways<GroupMessageEvent> {
// 只统计生效的群聊
if(!PluginConfig.groupsActivated.any { it == group.id })
return@subscribeAlways

if(bot.getGroup(group.id)!!.botPermission == MemberPermission.MEMBER)
return@subscribeAlways
// 检查机器人是否有管理权限
val botPermission = this.group.botPermission;
val hasProvilege = botPermission == MemberPermission.OWNER || botPermission == MemberPermission.ADMINISTRATOR

// 检查发言者是否有管理权限
val senderPermission = sender.permission
val senderHasPrivilege = senderPermission == MemberPermission.OWNER || senderPermission == MemberPermission.ADMINISTRATOR

val qq = sender.id
val nick = sender.nick
Expand All @@ -54,8 +60,8 @@ object AutoMutePlugin : KotlinPlugin(Env.pluginDescription)
return@subscribeAlways
}

// 只对普通群成员生效(管理员和群主无效)
if(sender.permission != MemberPermission.MEMBER)
// 只对普通群成员生效
if(senderHasPrivilege)
return@subscribeAlways

// 曾经的违规次数
Expand All @@ -73,10 +79,6 @@ object AutoMutePlugin : KotlinPlugin(Env.pluginDescription)
else
msg

// 检查机器人是否有管理权限
val botPermission = this.group.botPermission;
val hasProvilege = botPermission == MemberPermission.OWNER || botPermission == MemberPermission.ADMINISTRATOR

// 构建报告消息
val actions = mutableListOf<String>()

Expand Down

0 comments on commit 5b959dc

Please sign in to comment.