Class: Lita::Adapters::Gitter

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

Overview

Gitter adapter for the Lita chat bot.

Defined Under Namespace

Classes: Connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



16
17
18
# File 'lib/lita/adapters/gitter.rb', line 16

def connection
  @connection
end

Instance Method Details

#runObject

Delegates main loop execution to Connection Adapter



20
21
22
23
24
25
# File 'lib/lita/adapters/gitter.rb', line 20

def run
  return if connection

  @connection = Connection.new(robot, config)
  connection.run
end

#send_messages(target, messages) ⇒ Object

Sends one or more messages to a user or room.

Parameters:

  • target (Lita::Source)

    The user or room to send messages to.

  • messages (Array<String>)

    An array of messages to send.



32
33
34
35
36
# File 'lib/lita/adapters/gitter.rb', line 32

def send_messages(target, messages)
  messages.reject(&:empty?).each do |message|
    connection.send_message(target, message)
  end
end

#shut_downObject



38
39
40
41
42
43
# File 'lib/lita/adapters/gitter.rb', line 38

def shut_down
  return unless connection

  connection.shut_down
  robot.trigger(:disconnected)
end