Class: TARS::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/tars/bot.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBot

Returns a new instance of Bot.



37
38
39
# File 'lib/tars/bot.rb', line 37

def initialize
  @cmds = {}
end

Class Attribute Details

.cmdsObject

Returns the value of attribute cmds.



34
35
36
# File 'lib/tars/bot.rb', line 34

def cmds
  @cmds
end

Instance Method Details

#execute(command, update) ⇒ Object



45
46
47
48
49
# File 'lib/tars/bot.rb', line 45

def execute(command, update)
  return unless @cmds.key?(command)
  message = update.instance_variable_get('@message')
  @cmds[command].call(message, message['chat']['id'])
end

#on(command, &block) ⇒ Object



41
42
43
# File 'lib/tars/bot.rb', line 41

def on(command, &block)
  @cmds[command] = block
end