From 21c667d0f41ca537f423934fdf89c6ca2ba9fec9 Mon Sep 17 00:00:00 2001 From: cokie Date: Mon, 15 Jan 2024 18:59:31 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20fix:=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../micro/function/domain/strategy/ArgsLengthCheck.kt | 6 +++--- .../function/domain/strategy/FunctionContextImpl.kt | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/ArgsLengthCheck.kt b/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/ArgsLengthCheck.kt index 4a27800..55f57d7 100644 --- a/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/ArgsLengthCheck.kt +++ b/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/ArgsLengthCheck.kt @@ -24,9 +24,9 @@ class ArgsLengthCheck { val inspector = instance.get() try { when { - cmd.lowercase() == Cmd.Mj.code -> inspector.mj(args) - cmd.lowercase() == Cmd.Chat.code -> inspector.chat(args) - cmd.lowercase() == Cmd.Emoji.code -> inspector.emoji(args) + cmd.lowercase() == Cmd.Mj.cmd -> inspector.mj(args) + cmd.lowercase() == Cmd.Chat.cmd -> inspector.chat(args) + cmd.lowercase() == Cmd.Emoji.cmd -> inspector.emoji(args) } } catch (ex: ConstraintViolationException) { CmdException.fail(ex) diff --git a/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/FunctionContextImpl.kt b/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/FunctionContextImpl.kt index 90a5439..df60be1 100644 --- a/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/FunctionContextImpl.kt +++ b/tokisaki-function/src/main/kotlin/io/micro/function/domain/strategy/FunctionContextImpl.kt @@ -28,7 +28,7 @@ class FunctionContextImpl( @PostConstruct fun allocateCommandServices() { for (commandService in commandServices) { - allocationCommandServices[commandService.cmd().code] = commandService + allocationCommandServices[commandService.cmd().cmd] = commandService if (commandService is ImageTask) { allocationImageTask[commandService.cmd()] = commandService } @@ -36,15 +36,15 @@ class FunctionContextImpl( } override fun call(cmd: Cmd, args: MutableList, config: Map): Uni { - val code = cmd.code - ArgsLengthCheck.check(code, args) - return with(allocationCommandServices[code.lowercase()]) { + val cmd = cmd.cmd + ArgsLengthCheck.check(cmd, args) + return with(allocationCommandServices[cmd.lowercase()]) { this?.invoke(args, config) ?: CmdException.nonImplemented() } } override fun config(cmd: Cmd): ConfigHint? { - return with(allocationCommandServices[cmd.code.lowercase()]) { this?.configHint() } + return with(allocationCommandServices[cmd.cmd.lowercase()]) { this?.configHint() } } override fun menu(): Uni {