Sha256: 4899dc35b927e8bb66af31a596ba7a7395f41ab9570672d67b7ac78f0a20dc42

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

require 'lita'
require 'lita/adapters/glip/connector'
require 'lita/adapters/glip/message_handler'
require 'lita/adapters/glip/room_creator'
require 'lita/adapters/glip/user_creator'

module Lita
  module Adapters
    class Glip < Adapter
      namespace 'glip'

      # Required attributes
      config :app_key, type: String, required: true
      config :app_secret, type: String, required: true
      config :server_url, type: String, default: 'platform.devtest.ringcentral.com'

      config :username, type: String, required: true
      config :extension, type: String
      config :password, type: String, required: true
      config :token, type: String

      def initialize(robot)
        super
        @connector = Connector.new(
          robot,
          config.app_key,
          config.app_secret,
          config.server_url,
          config.username,
          config.extension,
          config.password,
          config.token
        )
      end

      def run
        @connector.connect
        sleep
      rescue Interrupt
        shut_down
      end

      def send_messages(target, strings)
        Lita.logger.info 'Sending Messages via Glip'
        @connector.message target.room_object.id, strings
      end

      def shut_down
        robot.trigger :disconnected
      end
    end

    Lita.register_adapter :glip, Glip
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lita-glip-0.1.0 lib/lita/adapters/glip.rb
lita-glip-0.0.4 lib/lita/adapters/glip.rb
lita-glip-0.0.3 lib/lita/adapters/glip.rb
lita-glip-0.0.2 lib/lita/adapters/glip.rb
lita-glip-0.0.1 lib/lita/adapters/glip.rb