Closed facorazza closed 5 years ago
Well, we can pass them to a catch all handler, or pass them to onUpdate when no match command found.
My idea would be to have a structure like this one:
bot.onUpdate(updateHandler)
bot.onCommand("command_a", commandAHandler)
bot.onCommand("command_b", commandBHandler)
bot.onCommand("command_c", commandCHandler)
bot.onUnknownCommand(unknownCommandHandler)
I guess if we did like so:
bot.onCommand("command_a", commandAHandler)
bot.onCommand("command_b", commandBHandler)
bot.onCommand("command_c", commandCHandler)
bot.onUpdate(updateHandler)
where the unknown command is caught as a regular message by onUpdate()
, it would work as well, but it might be confusing to mix messages and commands into one proc when commands usually have their own.
Could we overload onCommand()
to catch unknown commands? I would still prefer to use a separate proc though.
I'd like to use a proc like this one in
events.nim
:but I'm not sure how things are handled so I'm asking for help.
Perhaps, this new proc is not necessary. However, we must be sure not to catch commands already processed with
onCommand()
.