diff --git a/src/telepathy/bot.cr b/src/telepathy/bot.cr index cf1fa67..f066be0 100644 --- a/src/telepathy/bot.cr +++ b/src/telepathy/bot.cr @@ -8,6 +8,8 @@ module Telepathy @this_user = get_me @last_update_id = uninitialized Int64? @last_update_id = nil + @command_hooks = {} of String => Update, Array(String) -> String + @message_hooks = [] of Update -> String end def get_me @@ -26,5 +28,13 @@ module Telepathy updates.last?.try { |update| @last_update_id = update.update_id + 1 } return updates end + + def command(command_name, &block: Update, Array(String) -> String) + @command_hooks[command_name] = block + end + + def message(&block: Update -> String) + @message_hooks.push(block) + end end end