class LogStash::Inputs::Irc
Read events from an IRC Server.
Public Instance Methods
register()
click to toggle source
# File lib/logstash/inputs/irc.rb, line 43 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 end queue = @irc_queue @bot.on :channel do |m| queue << m end end
run(output_queue)
click to toggle source
# File lib/logstash/inputs/irc.rb, line 67 def run(output_queue) Thread.new(@bot) do |bot| bot.start end loop do msg = @irc_queue.pop if msg.user @codec.decode(msg.message) do |event| decorate(event) event["channel"] = msg.channel.to_s event["nick"] = msg.user.nick event["server"] = "#{@host}:#{@port}" output_queue << event end end end end