chore: use user role instead of admin list

This commit is contained in:
2024-10-19 19:29:03 +08:00
parent 9381ef8637
commit 8fd92b8fed
5 files changed
+60 -64

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
[versions]
kotlinVersion = "2.0.20"
ronebotVersion = "1.13.5"
ronebotVersion = "1.13.6"
shadowVersion = "8.3.0"
okhttpVersion = "5.0.0-alpha.14"
exposedVersion = "0.53.0"
@@ -8,7 +8,6 @@
package cn.rtast.fancybot.commands
import cn.rtast.fancybot.annotations.CommandDescription
import cn.rtast.fancybot.configManager
import cn.rtast.fancybot.enums.CommandAction
import cn.rtast.fancybot.util.file.insertActionRecord
import cn.rtast.rob.entity.GroupMessage
@@ -20,12 +19,12 @@ class EchoCommand : BaseCommand() {
override val commandNames = listOf("/echo")
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
if (message.sender.userId !in configManager.admins) {
message.reply("你不许用echo")
return
}
if (message.sender.isAdmin || message.sender.isOwner) {
listener.sendGroupMessage(message.groupId, args.joinToString(" "))
insertActionRecord(CommandAction.Echo, message.sender.userId)
} else {
message.reply("你不许用echo")
}
}
}
@@ -34,11 +33,11 @@ class ShuffleEchoCommand : BaseCommand() {
override val commandNames = listOf("/secho", "/se")
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
if (message.sender.userId !in configManager.admins) {
message.reply("你不许用echo")
return
}
if (message.sender.isAdmin || message.sender.isOwner) {
message.reply(message.rawMessage.toList().shuffled().joinToString(""))
insertActionRecord(CommandAction.Echo, message.sender.userId)
} else{
message.reply("你不许用echo")
}
}
}
@@ -8,7 +8,6 @@
package cn.rtast.fancybot.commands.misc
import cn.rtast.fancybot.annotations.CommandDescription
import cn.rtast.fancybot.configManager
import cn.rtast.fancybot.enums.CommandAction
import cn.rtast.fancybot.util.file.insertActionRecord
import cn.rtast.rob.entity.ArrayMessage
@@ -22,7 +21,7 @@ class AntiRevokeCommand : BaseCommand() {
override val commandNames = listOf("/revoke", "/rv")
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
if (message.sender.userId !in configManager.admins) message.reply("你不许用防撤回")
if (message.sender.isAdmin || message.sender.isOwner) {
val messageId = args.first().toLong()
val getMsg = listener.getMessage(messageId)
val msgList = mutableListOf<ArrayMessage>()
@@ -31,5 +30,8 @@ class AntiRevokeCommand : BaseCommand() {
msgList.addAll(getMsg.message)
listener.sendGroupMessage(message.groupId, msgList)
insertActionRecord(CommandAction.AntiRevoke, message.sender.userId, getMsg.messageId.toString())
} else {
message.reply("你不许用防撤回")
}
}
}
@@ -49,17 +49,13 @@ class SendMailCommand : BaseCommand() {
message.reply("发送`/mail <收件人地址>`即可发送测试邮件~")
return
}
if (message.sender.userId !in configManager.admins) {
val msg = MessageChain.Builder()
.addReply(message.messageId)
.addText("你不许发邮件")
.build()
listener.sendGroupMessage(message.groupId, msg)
return
}
if (message.sender.isAdmin || message.sender.isOwner) {
val target = args.first()
this.sendMail(target)
message.reply("正在发送邮件, 请查收~(可能会出现在垃圾桶中~)")
insertActionRecord(CommandAction.SendMail, message.sender.userId, target)
} else {
message.reply("你不许发邮件")
}
}
}
@@ -8,7 +8,6 @@
package cn.rtast.fancybot.commands.niuzi
import cn.rtast.fancybot.annotations.CommandDescription
import cn.rtast.fancybot.configManager
import cn.rtast.fancybot.niuziBankManager
import cn.rtast.fancybot.niuziManager
import cn.rtast.fancybot.util.misc.getUserName
@@ -27,10 +26,7 @@ class NiuziManagerCommand : BaseCommand() {
message.reply("此命令可以管理成员的牛子或者银行账户")
return
}
if (message.sender() !in configManager.admins) {
message.reply("你没权限呢!")
return
}
if (message.sender.isAdmin || message.sender.isOwner) {
val target = message.message.find { it.type == ArrayMessageType.at }!!.data.qq!!.toLong()
val method = args[1]
val amount = args.last().toDouble()
@@ -64,5 +60,8 @@ class NiuziManagerCommand : BaseCommand() {
}
}
}
} else {
message.reply("你没权限呢!")
}
}
}