mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 00:30:17 +08:00
change command structure
This commit is contained in:
parent
d16104b0ad
commit
f75c8ae28d
@ -17,6 +17,7 @@ import net.mamoe.mirai.console.MiraiConsole
|
|||||||
import net.mamoe.mirai.console.plugins.PluginBase
|
import net.mamoe.mirai.console.plugins.PluginBase
|
||||||
import net.mamoe.mirai.message.data.Message
|
import net.mamoe.mirai.message.data.Message
|
||||||
import java.lang.reflect.Member
|
import java.lang.reflect.Member
|
||||||
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
internal const val FOR_BINARY_COMPATIBILITY = "for binary compatibility"
|
internal const val FOR_BINARY_COMPATIBILITY = "for binary compatibility"
|
||||||
@ -35,14 +36,43 @@ interface Command {
|
|||||||
* 当所有的 sub 方法均不满足时, 原始参数将送到此方法调用
|
* 当所有的 sub 方法均不满足时, 原始参数将送到此方法调用
|
||||||
* 如果 arg 为 String, 他会被包装为 PlainText(AKA PlainMessage)
|
* 如果 arg 为 String, 他会被包装为 PlainText(AKA PlainMessage)
|
||||||
*/
|
*/
|
||||||
|
@Permission(CommandPermission.Console::class)
|
||||||
suspend fun CommandSender.onDefault(args: List<Message>): Boolean
|
suspend fun CommandSender.onDefault(args: List<Message>): Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在更多的情况下, 你应当使用 @SubCommand 来注册一共 sub 指令
|
* 在更多的情况下, 你应当使用 @SubCommand 来注册一共 sub 指令
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这是个例子
|
||||||
|
@SubCommand("add")
|
||||||
|
@Permission(CommandPermission.Console::class)
|
||||||
|
@Usage("禁言一个群员")
|
||||||
|
suspend fun CommandSender.onMyMethod1(
|
||||||
|
@Name("被禁言的人") member: Member,
|
||||||
|
@Name("时间") time:Int
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
|
annotation class Permission(val permission:KClass<*>)
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
|
annotation class Usage(val usage:String)
|
||||||
|
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||||
|
annotation class Name(val name:String)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
|
annotation class SubCommand(
|
||||||
|
val name:String
|
||||||
|
){
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 指令实际参数列表. 参数顺序与 [Command.descriptor] 的 [CommandDescriptor.params] 相同.
|
* 指令实际参数列表. 参数顺序与 [Command.descriptor] 的 [CommandDescriptor.params] 相同.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user