require "sinbotra/bot/conversation" require "sinbotra/bot/conversation_repo" require "sinbotra/bot/user" require "sinbotra/bot/user_repo" require "sucker_punch" module Sinbotra class Bot class << self def handle(provider, entry) perform_async(provider, entry) end def add_handler(provider, handler) @handlers ||= {} @handlers[provider.to_sym] = handler end def receive(provider, msg) handler = @handlers[provider.to_sym] handler.handle_message(msg) end end include SuckerPunch::Job def perform(provider, msg) # THis needs to be done elsewhere msg["entry"].first["messaging"].each do |m| Sinbotra::Bot.receive(provider, m) end end end end