Class: Sinbotra::Bot
- Inherits:
-
Object
show all
- Includes:
- SuckerPunch::Job
- Defined in:
- lib/sinbotra/bot.rb,
lib/sinbotra/bot/user.rb,
lib/sinbotra/bot/user_repo.rb,
lib/sinbotra/bot/conversation.rb,
lib/sinbotra/bot/conversation_repo.rb,
lib/sinbotra/bot/default_message_history.rb
Defined Under Namespace
Classes: Conversation, ConversationRepo, DefaultMessageHistory, User, UserRepo
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.add_handler(provider, handler) ⇒ Object
16
17
18
19
|
# File 'lib/sinbotra/bot.rb', line 16
def add_handler(provider, handler)
@handlers ||= {}
@handlers[provider.to_sym] = handler
end
|
.handle(provider, entry) ⇒ Object
11
12
13
14
|
# File 'lib/sinbotra/bot.rb', line 11
def handle(provider, entry)
Sinbotra::Config.logger.debug("ENTRY DEBUG:\n" + entry.inspect) if ENV["DEBUG"]
perform_async(provider, entry)
end
|
.receive(provider, msg) ⇒ Object
21
22
23
24
25
|
# File 'lib/sinbotra/bot.rb', line 21
def receive(provider, msg)
handler = @handlers[provider.to_sym]
Sinbotra::Config.logger.debug("MESSAGE DEBUG:\n" + msg.inspect) if ENV["DEBUG"]
handler.handle_message(msg)
end
|
Instance Method Details
30
31
32
33
34
35
|
# File 'lib/sinbotra/bot.rb', line 30
def perform(provider, msg)
msg["entry"].first["messaging"].each do |m|
Sinbotra::Bot.receive(provider, m)
end
end
|