From 8a01dcc556685a7794e9213cc0a658e18b5f08f8 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 12 Sep 2020 16:25:36 +0800 Subject: [PATCH] Support parsing self for PermissibleIdentifierArgumentParser --- .../command/description/CommandArgumentParserBuiltins.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 b78fc129c..3484296f1 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 @@ -320,7 +320,8 @@ public object PermissionIdArgumentParser : CommandArgumentParser { @ExperimentalPermission public object PermissibleIdentifierArgumentParser : CommandArgumentParser { override fun parse(raw: String, sender: CommandSender): PermissibleIdentifier { - return kotlin.runCatching { AbstractPermissibleIdentifier.parseFromString(raw) }.getOrElse { + return if (raw == "~") sender.identifier + else kotlin.runCatching { AbstractPermissibleIdentifier.parseFromString(raw) }.getOrElse { illegalArgument("无法解析 $raw 为 PermissibleIdentifier") } }