Class: BotBrain::Brain

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

Instance Method Summary collapse

Constructor Details

#initialize(token, dictionary) ⇒ Brain

Returns a new instance of Brain.



12
13
14
15
16
# File 'lib/bot_brain.rb', line 12

def initialize(token, dictionary)
  @token = token
  @dictionary = dictionary
  @chats = {}
end

Instance Method Details

#answer(raw_message) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bot_brain.rb', line 18

def answer(raw_message)
  message = BotBrain::Message.new(raw_message)
  add_to_chat(message)
  command = @dictionary.get_command(message)
  text = command.answer(message)
  api.call('sendMessage', chat_id: message.chat_id, text: text)
end