diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt index ff438859d..733646b84 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt @@ -97,6 +97,10 @@ abstract class RawCommand(name:String, alias: Array = arrayOf()):Command } + @Command.Permission(CommandPermission.Default::class) + abstract fun onCommand(list: List) + + } /** * 解析完成的指令实际参数列表. 参数顺序与 [Command.descriptor] 的 [CommandDescriptor.params] 相同. diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermission.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermission.kt index e1eff53c2..86c292c3a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermission.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandPermission.kt @@ -28,7 +28,6 @@ interface CommandPermission { */ fun CommandSender.hasPermission(): Boolean - /** * 满足两个权限其中一个即可使用指令 */ // no extension for Java @@ -39,7 +38,6 @@ interface CommandPermission { */ // no extension for Java infix fun and(another: CommandPermission): CommandPermission = AndCommandPermission(this, another) - /** * 任何人都可以使用这个指令 */ @@ -55,7 +53,7 @@ interface CommandPermission { } /** - * 来自任何 [Bot] 的任何一个管理员或群主都可以使用这个指令 + * 来自任何 [Bot] 的任何一个群管理员或群主都可以使用这个指令 */ object Operator : CommandPermission { override fun CommandSender.hasPermission(): Boolean { @@ -117,10 +115,8 @@ inline fun AnonymousCommandPermission(crossinline block: CommandSender.() -> Boo inline fun CommandSender.hasPermission(permission: CommandPermission): Boolean = permission.run { this@hasPermission.hasPermission() } - inline fun CommandPermission.hasPermission(sender: CommandSender): Boolean = this.run { sender.hasPermission() } - internal class OrCommandPermission( private val first: CommandPermission, private val second: CommandPermission