lib/boty/session.rb in boty-0.1.0 vs lib/boty/session.rb in boty-0.1.1

- old
+ new

@@ -20,41 +20,40 @@ def on_connect(ws) ws.on :message do |event| begin on_message event, @bot rescue StandardError => e - logger.error "Message #{event} could not be processed. #{e.message}" - logger.debug e.backtrace.reduce("") { |msg, line| msg << "#{line}\n" } + log_error e, "Message #{event} could not be processed." end end end def login - logger.debug { "Logging in against slack right now" } + logger.debug do "Logging in against slack right now" end @slack_info = Slack.rtm.start - logger.debug { "yep! logged in!" } + logger.debug do "yep! logged in!" end @session_url = @slack_info["url"] end def initialize_bot(&block) Bot.new(@slack_info["self"]).tap { |bot| DSL.new(bot).instance_eval(&block) if block_given? - logger.debug { "Bot is configured and ready to go!" } + logger.debug do "Bot is configured and ready to go!" end } end def on_message(event, bot) - logger.debug { "Message arrived. Creating bot event" } + logger.debug do "Message arrived. Creating bot event" end bot.event JSON.parse(event.data) end def on_close logger.debug { "bye bye" } - #todo try to reconnect (stablish_connection) unless is an em interrupt + # TODO: try to reconnect (stablish_connection) unless is an em interrupt end def stablish_connection - logger.debug { "Starting to listen on #{@session_url}" } + logger.debug do "Starting to listen on #{@session_url}" end ws = Faye::WebSocket::Client.new @session_url ws.on :close do on_close end on_connect ws end end