class Bot
Encapsulates the Bot
behavior, inherit your app from Bot
class
Public Class Methods
commands()
click to toggle source
# File lib/telegram/bot.rb, line 17 def self.commands @commands ||= {} end
on(command, &block)
click to toggle source
# File lib/telegram/bot.rb, line 21 def self.on(command, &block) commands[:"#{command}"] = block end
Public Instance Methods
call(env)
click to toggle source
# File lib/telegram/bot.rb, line 5 def call(env) return [403, {}, []] unless Telegram.path_verified env['PATH_INFO'] update = Telegram.parse_update(env['rack.input'].read) self.class.commands.each do |command, block| instance_exec(update, &block) if update.message.contains_command?(command) end [200, {}, []] end