Skip to content

Commit

Permalink
🎨 fix: 修复
Browse files Browse the repository at this point in the history
  • Loading branch information
cokie committed Jan 15, 2024
1 parent af6cc62 commit 21c667d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ 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
}
}
}

override fun call(cmd: Cmd, args: MutableList<String>, config: Map<String, *>): Uni<MessageChain> {
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<MessageChain> {
Expand Down

0 comments on commit 21c667d

Please sign in to comment.