Add PlainTextArgumentParser

This commit is contained in:
Him188 2020-09-20 19:33:21 +08:00
parent 453ad8f9e2
commit e10a17ccd4
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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"
*/