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

- old
+ new

@@ -1,28 +1,37 @@ module Lita module Adapters class Campfire < Adapter class Connector def initialize(robot, opts) - @robot = robot - @subdomain = opts.fetch(:subdomain) - @apikey = opts.fetch(:apikey) - @rooms = opts.fetch(:rooms) - @debug = opts.fetch(:debug) { false } + @robot = robot + @subdomain = opts.fetch(:subdomain) + @apikey = opts.fetch(:apikey) + @rooms = opts.fetch(:rooms) + @debug = opts.fetch(:debug) { false } + @tinder_options = opts.fetch(:tinder_options) { Hash.new } end def connect @campfire = Tinder::Campfire.new(@subdomain, token: @apikey) end + def disconnect + Lita.logger.info("Disconnecting from Campfire.") + rooms.each do |room_id| + room = fetch_room(room_id) + room.leave + end + end + def join_rooms rooms.each do |room_id| room = fetch_room(room_id) room.join callback = Callback.new(@robot, room) callback.register_users - callback.listen + callback.listen(@tinder_options) end end def send_messages(room_id, messages) fetch_room(room_id).tap do |my_room| @@ -34,15 +43,11 @@ end end end end - def disconnect - Lita.logger.info("Disconnecting from Campfire.") - rooms.each do |room_id| - room = fetch_room(room_id) - room.leave - end + def set_topic(room_id, topic) + fetch_room(room_id).topic = topic end private attr_reader :rooms \ No newline at end of file