class LogStash::Outputs::Irc

Write events to IRC

Public Instance Methods

receive(event) click to toggle source
# File lib/logstash/outputs/irc.rb, line 71
def receive(event)
  return unless output?(event)
  @logger.debug("Sending message to channels", :event => event)
  text = event.sprintf(@format)
  @bot.channels.each do |channel|
    @logger.debug("Sending to...", :channel => channel, :text => text)
    channel.msg(text)
  end # channels.each
end
register() click to toggle source
# File lib/logstash/outputs/irc.rb, line 47
def register
  require "cinch"
  @irc_queue = Queue.new
  @logger.info("Connecting to irc server", :host => @host, :port => @port, :nick => @nick, :channels => @channels)

  @bot = Cinch::Bot.new
  @bot.loggers.clear
  @bot.configure do |c|
    c.server = @host
    c.port = @port
    c.nick = @nick
    c.user = @user
    c.realname = @real
    c.channels = @channels
    c.password = @password.value rescue nil
    c.ssl.use = @secure
    c.messages_per_second = @messages_per_second if @messages_per_second
  end
  Thread.new(@bot) do |bot|
    bot.start
  end
end