diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentContext.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentContext.kt index 47d02e1c3..cacea64e0 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentContext.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentContext.kt @@ -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 diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParserBuiltins.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParserBuiltins.kt index 851ba009c..28d49cd11 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParserBuiltins.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgumentParserBuiltins.kt @@ -95,6 +95,17 @@ public object ImageArgumentParser : InternalCommandArgumentParserExtensions { + 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" */