Class: Lita::Adapters::Twitter
- Inherits:
-
Adapter
- Object
- Adapter
- Lita::Adapters::Twitter
- Defined in:
- lib/lita/adapters/twitter.rb,
lib/lita/adapters/twitter/connector.rb
Defined Under Namespace
Classes: Connector
Instance Attribute Summary collapse
-
#connector ⇒ Object
readonly
Returns the value of attribute connector.
Instance Method Summary collapse
-
#initialize(robot) ⇒ Twitter
constructor
A new instance of Twitter.
- #join(user) ⇒ Object
- #mention_format(name) ⇒ Object
- #part(user) ⇒ Object
- #run ⇒ Object
- #send_messages(target, strings) ⇒ Object
- #set_topic(target, topic) ⇒ Object
- #shut_down ⇒ Object
Constructor Details
#initialize(robot) ⇒ Twitter
Returns a new instance of Twitter.
13 14 15 16 17 18 19 20 21 |
# File 'lib/lita/adapters/twitter.rb', line 13 def initialize(robot) super @connector = Connector.new(robot, api_key: config.api_key, api_secret: config.api_secret, access_token: config.access_token, access_token_secret: config.access_token_secret, ) end |
Instance Attribute Details
#connector ⇒ Object (readonly)
Returns the value of attribute connector.
22 23 24 |
# File 'lib/lita/adapters/twitter.rb', line 22 def connector @connector end |
Instance Method Details
#join(user) ⇒ Object
24 25 26 |
# File 'lib/lita/adapters/twitter.rb', line 24 def join(user) connector.join(user) end |
#mention_format(name) ⇒ Object
51 52 53 |
# File 'lib/lita/adapters/twitter.rb', line 51 def mention_format(name) "@#{name}" end |
#part(user) ⇒ Object
28 29 30 |
# File 'lib/lita/adapters/twitter.rb', line 28 def part(user) connector.part(user) end |
#run ⇒ Object
40 41 42 43 44 45 |
# File 'lib/lita/adapters/twitter.rb', line 40 def run robot.trigger(:connected) connector.connect rescue Interrupt shut_down end |
#send_messages(target, strings) ⇒ Object
36 37 38 |
# File 'lib/lita/adapters/twitter.rb', line 36 def (target, strings) connector.(target, strings) end |
#set_topic(target, topic) ⇒ Object
32 33 34 |
# File 'lib/lita/adapters/twitter.rb', line 32 def set_topic(target, topic) connector.update_name(topic) end |
#shut_down ⇒ Object
47 48 49 |
# File 'lib/lita/adapters/twitter.rb', line 47 def shut_down robot.trigger(:disconnected) end |