Class: TARS::Bot
- Inherits:
-
Object
- Object
- TARS::Bot
- Defined in:
- lib/tars/bot.rb
Class Attribute Summary collapse
-
.cmds ⇒ Object
Returns the value of attribute cmds.
Instance Method Summary collapse
- #execute(command, update) ⇒ Object
-
#initialize ⇒ Bot
constructor
A new instance of Bot.
- #on(command, &block) ⇒ Object
Constructor Details
#initialize ⇒ Bot
Returns a new instance of Bot.
37 38 39 |
# File 'lib/tars/bot.rb', line 37 def initialize @cmds = {} end |
Class Attribute Details
.cmds ⇒ Object
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) = update.instance_variable_get('@message') @cmds[command].call(, ['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 |