Class: LogStash::Outputs::Irc

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/irc.rb

Overview

Write events to IRC

Instance Method Summary collapse

Instance Method Details

#botObject



58
59
60
# File 'lib/logstash/outputs/irc.rb', line 58

def bot
  @bot
end

#inject_bot(bot) ⇒ Object



53
54
55
56
# File 'lib/logstash/outputs/irc.rb', line 53

def inject_bot(bot)
  @bot = bot
  self
end

#receive(event) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/logstash/outputs/irc.rb', line 86

def receive(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(pre_string) if !@pre_string.nil?
    channel.msg(text)
    channel.msg(post_string) if !@post_string.nil?
  end # channels.each
end

#registerObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/logstash/outputs/irc.rb', line 62

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