Sha256: 0776764322269ceb0aed57a68f103c40b1e321bc5e0e17f8178e5d7dec72d62e

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 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: rooms,
          debug: config.debug
        )
      end

      def run
        connector.connect
        connector.join_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

2 entries across 2 versions & 1 rubygems

Version Path
lita-campfire-0.1.3 lib/lita/adapters/campfire.rb
lita-campfire-0.1.2 lib/lita/adapters/campfire.rb