class Fluent::Plugin::IRCOutput::IRCConnection
Attributes
joined[R]
log[RW]
nick[RW]
password[RW]
real[RW]
user[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_irc.rb, line 182 def initialize(*args) super @joined = {} end
Public Instance Methods
join(channel)
click to toggle source
# File lib/fluent/plugin/out_irc.rb, line 239 def join(channel) IRCParser.message(:join) do |m| m.channels = channel write m end log.debug { "out_irc: join to #{channel}" } end
joined?(channel)
click to toggle source
# File lib/fluent/plugin/out_irc.rb, line 235 def joined?(channel) @joined[channel] end
on_connect()
click to toggle source
# File lib/fluent/plugin/out_irc.rb, line 187 def on_connect if @password IRCParser.message(:pass) do |m| m.password = @password write m end end IRCParser.message(:nick) do |m| m.nick = @nick write m end IRCParser.message(:user) do |m| m.user = @user m.postfix = @real write m end end
on_read(data)
click to toggle source
# File lib/fluent/plugin/out_irc.rb, line 205 def on_read(data) data.each_line do |line| begin msg = IRCParser.parse(line) log.debug { "out_irc: on_read :#{msg.class.to_sym}" } case msg.class.to_sym when :rpl_welcome log.info { "out_irc: welcome \"#{msg.nick}\" to \"#{msg.prefix}\"" } when :ping IRCParser.message(:pong) do |m| m.target = msg.target m.body = msg.body write m end when :join log.info { "out_irc: joined to #{msg.channels.join(', ')}" } msg.channels.each {|channel| @joined[channel] = true } when :err_nick_name_in_use log.warn "out_irc: nickname \"#{msg.error_nick}\" is already in use. use \"#{@nick}_\" instead." @nick = "#{@nick}_" on_connect when :error log.warn "out_irc: an error occured. \"#{msg.error_message}\"" end rescue #TODO end end end
send_message(command, channel, message)
click to toggle source
# File lib/fluent/plugin/out_irc.rb, line 247 def send_message(command, channel, message) join(channel) unless joined?(channel) IRCParser.message(command) do |m| m.target = channel m.body = message write m end channel # return channel for test end