Class: Rodbot::Relay

Inherits:
Object
  • Object
show all
Includes:
Memoize
Defined in:
lib/rodbot/relay.rb

Overview

Base class for relay extensions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Memoize

included

Class Method Details

.say(text, on: nil, room: nil) ⇒ Boolean

Post a message via one or more relay services

By default, messages are posted via all relay services which have “say true” configured in their corresponding config blocks. To further narrow it to exactly one relay service, use the on argument.

Parameters:

  • text (String)

    message to post

  • on (Symbol, nil) (defaults to: nil)

    post via this relay service only

  • room (String, nil) (defaults to: nil)

    post to this room (aka: channel, group etc)

Returns:

  • (Boolean)

    false if at least one relay refused the connection or true otherwise



26
27
28
29
30
31
32
# File 'lib/rodbot/relay.rb', line 26

def say(text, on: nil, room: nil)
  Rodbot.config(:plugin).select do |extension, config|
    config[:say] == true && (!on || extension == on)
  end.keys.inject(true) do |success, extension|
    write(Rodbot::Message.new(text, room: room).dump, extension) && success
  end
end

Instance Method Details

#loopsArray<Proc>

This method is abstract.

Loops which will be called by the relay service

Returns:

  • (Array<Proc>)


58
59
60
# File 'lib/rodbot/relay.rb', line 58

def loops
  fail(Rodbot::RelayError, "loops method is not implemented")
end