Class: Bot
- Inherits:
-
Object
- Object
- Bot
- Defined in:
- lib/telegram/bot.rb
Overview
Encapsulates the Bot behavior, inherit your app from Bot class
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.commands ⇒ Object
17 18 19 |
# File 'lib/telegram/bot.rb', line 17 def self.commands @commands ||= {} end |
.on(command, &block) ⇒ Object
21 22 23 |
# File 'lib/telegram/bot.rb', line 21 def self.on(command, &block) commands[:"#{command}"] = block end |
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# 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..contains_command?(command) end [200, {}, []] end |