Glip.shut_down()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
require 'lita'
2
require 'lita/adapters/glip/connector'
3
require 'lita/adapters/glip/message_handler'
4
require 'lita/adapters/glip/room_creator'
5
require 'lita/adapters/glip/user_creator'
6
7
module Lita
8
  module Adapters
9
    class Glip < Adapter
10
      namespace 'glip'
11
12
      # Required attributes
13
      config :app_key, type: String, required: true
14
      config :app_secret, type: String, required: true
15
      config :server_url, type: String, default: 'platform.devtest.ringcentral.com'
16
17
      config :username, type: String
18
      config :extension, type: String
19
      config :password, type: String
20
      config :token, type: String
21
22
      def initialize(robot)
23
        @robot = robot
24
      end
25
26
      def log
27
        Lita.logger
28
      end
29
30
      def initialize(robot)
0 ignored issues
show
Unused Code Bug introduced by
The method named Lita::Adapters::Glip#initialize has been defined twice. The first time in file /home/scrutinizer/build/package/lib/lita/adapters/glip.rb at line 22, the second time in file /home/scrutinizer/build/package/lib/lita/adapters/glip.rb at line 30. Please rename either of them, if you need them both.
Loading history...
31
        super
32
        @connector = Connector.new(
33
          robot,
34
          config.app_key,
35
          config.app_secret,
36
          config.server_url,
37
          config.username,
38
          config.extension,
39
          config.password,
40
          config.token
41
        )
42
      end
43
44
      def run
45
        @connector.connect
46
        sleep
47
      rescue Interrupt
48
        shut_down
49
      end
50
51
      def send_messages(target, strings)
52
        Lita.logger.info 'Sending Messages via Glip'
53
        @connector.message target.room_object.id, strings
54
      end
55
56
      def shut_down
57
        robot.trigger :disconnected
58
      end
59
    end
60
61
    Lita.register_adapter :glip, Glip
62
  end
63
end
64