Class: Cerberus::Publisher::IRC

Inherits:
Base
  • Object
show all
Defined in:
lib/cerberus/publisher/irc.rb

Class Method Summary collapse

Methods inherited from Base

formatted_message

Class Method Details

.publish(state, manager, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cerberus/publisher/irc.rb', line 6

def self.publish(state, manager, options)
  irc_options = options[:publisher, :irc]
  raise "There is no channel provided for IRC publisher" unless irc_options[:channel]
  subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
  message = subject + "\n" + '*' * subject.length + "\n" + body

  port             = irc_options[:port] || 6667
  nick             = irc_options[:nick] || 'cerberus'
  server           = irc_options[:server]
  channel          = '#' + irc_options[:channel]
  channel_password = irc_options[:channel_password]
  
  ShoutBot.shout("irc://#{nick}@#{server}:#{port}/#{channel}", channel_password) do |channel|
    message.split("\n").each { |line| channel.say line }
  end
  
end