mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Add PlainTextArgumentParser
This commit is contained in:
parent
453ad8f9e2
commit
e10a17ccd4
@ -21,6 +21,7 @@ import net.mamoe.mirai.console.permission.PermitteeId
|
||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.message.data.PlainText
|
||||
import kotlin.internal.LowPriorityInOverloadResolution
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.isSubclassOf
|
||||
@ -75,7 +76,9 @@ public interface CommandArgumentContext {
|
||||
Long::class with LongArgumentParser
|
||||
Double::class with DoubleArgumentParser
|
||||
Float::class with FloatArgumentParser
|
||||
|
||||
Image::class with ImageArgumentParser
|
||||
PlainText::class with PlainTextArgumentParser
|
||||
|
||||
Contact::class with ExistingContactArgumentParser
|
||||
User::class with ExistingUserArgumentParser
|
||||
|
@ -95,6 +95,17 @@ public object ImageArgumentParser : InternalCommandArgumentParserExtensions<Imag
|
||||
}
|
||||
}
|
||||
|
||||
public object PlainTextArgumentParser : InternalCommandArgumentParserExtensions<PlainText> {
|
||||
public override fun parse(raw: String, sender: CommandSender): PlainText {
|
||||
return PlainText(raw)
|
||||
}
|
||||
|
||||
override fun parse(raw: MessageContent, sender: CommandSender): PlainText {
|
||||
if (raw is PlainText) return raw
|
||||
return super.parse(raw, sender)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当字符串内容为(不区分大小写) "true", "yes", "enabled"
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user