lib/boty/session.rb in boty-0.0.14 vs lib/boty/session.rb in boty-0.0.15
- old
+ new
@@ -7,22 +7,22 @@
attr_reader :bot
def start(&block)
EM.run do
login
- bot = initialize_bot(&block)
-
+ @bot = initialize_bot(&block)
stablish_connection do |ws|
ws.on :message do |event|
begin
- on_message event, bot
+ on_message event, @bot
rescue StandardError => e
logger.error "Message #{event} could not be processed. #{e.message}"
end
end
end
end
+ self
end
private
def login
@@ -32,10 +32,10 @@
@session_url = @slack_info["url"]
end
def initialize_bot(&block)
Bot.new(@slack_info["self"], self).tap { |bot|
- block.call bot if block_given?
+ block.call ScriptDSL.new(bot) if block_given?
logger.debug { "bot is configured and ready to go!" }
}
end
def on_message(event, bot)