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
20
21
22
23
|
# File 'lib/sinbotra/bot.rb', line 20
def add_handler(provider, handler)
@handlers ||= {}
@handlers[provider.to_sym] = handler
end
|
.handle(provider, entry) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/sinbotra/bot.rb', line 11
def handle(provider, entry)
Sinbotra::Config.logger.debug("ENTRY DEBUG:\n" + entry.inspect) if ENV["DEBUG"]
if ENV["SINBOTRA_SYNCHRONOUS"]
new.perform(provider, entry)
else
perform_async(provider, entry)
end
end
|
.receive(provider, msg) ⇒ Object
25
26
27
28
29
|
# File 'lib/sinbotra/bot.rb', line 25
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
34
35
36
37
38
39
|
# File 'lib/sinbotra/bot.rb', line 34
def perform(provider, msg)
msg["entry"].first["messaging"].each do |m|
Sinbotra::Bot.receive(provider, m)
end
end
|