Class: Lita::Adapters::Twitter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/lita/adapters/twitter.rb,
lib/lita/adapters/twitter/connector.rb

Defined Under Namespace

Classes: Connector

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectorObject (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

#runObject



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 send_messages(target, strings)
  connector.message(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_downObject



47
48
49
# File 'lib/lita/adapters/twitter.rb', line 47

def shut_down
  robot.trigger(:disconnected)
end