Class: Lita::Adapters::Line::Client
- Inherits:
-
Object
- Object
- Lita::Adapters::Line::Client
- Defined in:
- lib/lita/adapters/line/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #format_msg(messages) ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #run ⇒ Object
- #send_messages(reply_token, messages) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 |
# File 'lib/lita/adapters/line/client.rb', line 9 def initialize(config) @client = ::Line::Bot::Client.new { |c| c.channel_secret = config.channel_secret c.channel_token = config.channel_token } end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/lita/adapters/line/client.rb', line 8 def client @client end |
Instance Method Details
#format_msg(messages) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/lita/adapters/line/client.rb', line 32 def format_msg() .map do || { type: :text, text: } end end |
#run ⇒ Object
16 17 18 19 20 |
# File 'lib/lita/adapters/line/client.rb', line 16 def run log.info "Running client" EM.run do end end |
#send_messages(reply_token, messages) ⇒ Object
26 27 28 29 30 |
# File 'lib/lita/adapters/line/client.rb', line 26 def (reply_token, ) = format_msg log.info "Send message to ##{reply_token}, #{}" client.(reply_token, ) end |
#stop ⇒ Object
22 23 24 |
# File 'lib/lita/adapters/line/client.rb', line 22 def stop EM.stop if EM.reactor_running? end |