Class: Feedbook::Notifiers::IRCNotifier

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/feedbook/notifiers/irc_notifier.rb

Instance Method Summary collapse

Instance Method Details

#load_configuration(configuration = {}) ⇒ NilClass

Load configuration for IRCNotifier

Parameters:

  • configuration (defaults to: {})

    {} [Hash] Configuration hash (required: address, domain, username, password, to, from, subject)

Returns:

  • (NilClass)

    nil



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/feedbook/notifiers/irc_notifier.rb', line 25

def load_configuration(configuration = {})
  irc_url     = configuration.fetch('url')
  irc_port    = configuration.fetch('port')
  ssl_enabled = configuration.fetch('ssl_enabled')

  @channel = configuration.fetch('channel')
  @nick    = configuration.fetch('nick')
  
  @client = IrcNotify::Client.build(irc_url, irc_port, ssl: ssl_enabled)

  puts 'Configuration loaded for IRCNotifier'
end

#notify(message) ⇒ NilClass

Sends notification to IRC

Parameters:

  • message (String)

    message to be send to IRC

Returns:

  • (NilClass)

    nil



13
14
15
16
17
18
19
# File 'lib/feedbook/notifiers/irc_notifier.rb', line 13

def notify(message)
  client.register(nick)
  client.notify(message)
  client.quit
  
  puts "New message has been notified on IRC: #{message}"
end