mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 00:20:19 +08:00
PermitteeIdValueArgumentParser: Parse numerical values as ExactUser for convenience
This commit is contained in:
parent
5bd6182a17
commit
5da481dd1b
@ -347,8 +347,15 @@ public object PermissionIdValueArgumentParser : InternalCommandValueArgumentPars
|
|||||||
public object PermitteeIdValueArgumentParser : InternalCommandValueArgumentParserExtensions<PermitteeId>() {
|
public object PermitteeIdValueArgumentParser : InternalCommandValueArgumentParserExtensions<PermitteeId>() {
|
||||||
override fun parse(raw: String, sender: CommandSender): PermitteeId {
|
override fun parse(raw: String, sender: CommandSender): PermitteeId {
|
||||||
return if (raw == "~") sender.permitteeId
|
return if (raw == "~") sender.permitteeId
|
||||||
else kotlin.runCatching { AbstractPermitteeId.parseFromString(raw) }.getOrElse {
|
else {
|
||||||
illegalArgument("无法解析 $raw 为被许可人 ID.")
|
kotlin.runCatching { AbstractPermitteeId.parseFromString(raw) }.getOrElse {
|
||||||
|
val long = raw.toLongOrNull()
|
||||||
|
if (long != null) {
|
||||||
|
return AbstractPermitteeId.ExactUser(long)// for convenience
|
||||||
|
}
|
||||||
|
|
||||||
|
illegalArgument("无法解析 $raw 为被许可人 ID.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user