ringcentral-ruby /
lita-glip
| 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
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 |