lib/lita/adapters/campfire/connector.rb in lita-campfire-0.1.4 vs lib/lita/adapters/campfire/connector.rb in lita-campfire-0.2.0

- old
+ new

@@ -10,11 +10,11 @@ @debug = opts.fetch(:debug) { false } @tinder_options = opts.fetch(:tinder_options) { Hash.new } end def connect - @campfire = Tinder::Campfire.new(@subdomain, token: @apikey) + @campfire = Tinder::Campfire.new(subdomain, token: apikey) end def disconnect Lita.logger.info("Disconnecting from Campfire.") rooms.each do |room_id| @@ -25,13 +25,13 @@ def join_rooms rooms.each do |room_id| room = fetch_room(room_id) room.join - callback = Callback.new(@robot, room) + callback = Callback.new(robot: robot, room: room, robot_id: robot_id) callback.register_users - callback.listen(@tinder_options) + callback.listen(tinder_options) end end def send_messages(room_id, messages) fetch_room(room_id).tap do |my_room| @@ -49,18 +49,23 @@ fetch_room(room_id).topic = topic end private - attr_reader :rooms + attr_reader :rooms, :subdomain, :apikey, :tinder_options, :robot + attr_accessor :campfire def fetch_room(room_id) - @campfire.find_room_by_id(room_id).tap do |room| + campfire.find_room_by_id(room_id).tap do |room| if room.nil? raise RoomNotAvailable, "Make sure you have access to room #{ room_id.inspect }" end end + end + + def robot_id + campfire.me.id end end end end end \ No newline at end of file