Support parsing an At to a Bot, close #128

This commit is contained in:
Him188 2020-08-28 11:34:46 +08:00
parent 5a5d45778a
commit 1bd1b5a4fd

View File

@ -97,6 +97,12 @@ public object ExistingBotArgumentParser : InternalCommandArgumentParserExtension
public override fun parse(raw: String, sender: CommandSender): Bot =
if (raw == "~") sender.inferBotOrFail()
else raw.findBotOrFail()
public override fun parse(raw: SingleMessage, sender: CommandSender): Bot =
if (raw is At) {
Bot.getInstanceOrNull(raw.target)
?: illegalArgument("@ 的对象不是一个 Bot")
} else super.parse(raw, sender)
}
/**