Sha256: 3c2eca254c1584c8c3ce50484a05351adda9bae7e1abd1945d801684935d5794

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Lita
  module Adapters
    class Campfire < Adapter
      require_configs :subdomain, :apikey, :rooms

      attr_reader :connector

      def initialize(robot)
        super

        @connector = Connector.new(
          robot,
          subdomain: config.subdomain,
          apikey: config.apikey,
          rooms: config.rooms,
          debug: config.debug
        )
      end

      def run
        connector.connect
        connector.join_rooms rooms
        sleep
      rescue Interrupt
        disconnect
      end

      def send_messages(target, messages)
        connector.send_messages(target.room, messages)
      end

      def set_topic(target, topic)
        connector.set_topic(target.room, topic)
      end

      def shut_down
        disconnect
      end

      private

      def config
          Lita.config.adapter
      end

      def rooms
        Array(config.rooms)
      end

      def disconnect
        connector.disconnect
      end
    end

    Lita.register_adapter(:campfire, Campfire)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-campfire-0.1 lib/lita/adapters/campfire.rb