lib/cerberus/publisher/irc.rb in cerberus-0.2.2 vs lib/cerberus/publisher/irc.rb in cerberus-0.2.3

- old
+ new

@@ -9,19 +9,22 @@ message = subject + "\n" + '*' * subject.length + "\n" + body channel = '#' + irc_options[:channel] bot = IRC.new(irc_options[:nick] || 'cerberus', irc_options[:server], irc_options[:port] || 6667) - IRCEvent.add_callback('endofmotd') { |event| - bot.add_channel(channel) - message.split("\n").each{|line| - bot.send_message(channel, line) + + silence_stream(STDOUT) { + IRCEvent.add_callback('endofmotd') { |event| + bot.add_channel(channel) + message.split("\n").each{|line| + bot.send_message(channel, line) + } + bot.send_quit } - bot.send_quit + begin + bot.connect #Why it always fails? + rescue Exception => e + puts e.message + end } - begin - bot.connect #Why it always fails? - rescue Exception => e - puts e.message - end end end