Class: Fluent::IRCOutput::IRCConnection
- Inherits:
-
Cool.io::TCPSocket
- Object
- Cool.io::TCPSocket
- Fluent::IRCOutput::IRCConnection
- Defined in:
- lib/fluent/plugin/out_irc.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#command ⇒ Object
Returns the value of attribute command.
-
#nick ⇒ Object
Returns the value of attribute nick.
-
#password ⇒ Object
Returns the value of attribute password.
-
#real ⇒ Object
Returns the value of attribute real.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(*args) ⇒ IRCConnection
constructor
A new instance of IRCConnection.
- #join(channel) ⇒ Object
- #joined?(channel) ⇒ Boolean
- #on_connect ⇒ Object
- #on_read(data) ⇒ Object
- #send_message(msg, channel) ⇒ Object
Constructor Details
#initialize(*args) ⇒ IRCConnection
Returns a new instance of IRCConnection.
155 156 157 158 |
# File 'lib/fluent/plugin/out_irc.rb', line 155 def initialize(*args) super @joined = {} end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
153 154 155 |
# File 'lib/fluent/plugin/out_irc.rb', line 153 def channel @channel end |
#command ⇒ Object
Returns the value of attribute command.
153 154 155 |
# File 'lib/fluent/plugin/out_irc.rb', line 153 def command @command end |
#nick ⇒ Object
Returns the value of attribute nick.
153 154 155 |
# File 'lib/fluent/plugin/out_irc.rb', line 153 def nick @nick end |
#password ⇒ Object
Returns the value of attribute password.
153 154 155 |
# File 'lib/fluent/plugin/out_irc.rb', line 153 def password @password end |
#real ⇒ Object
Returns the value of attribute real.
153 154 155 |
# File 'lib/fluent/plugin/out_irc.rb', line 153 def real @real end |
#user ⇒ Object
Returns the value of attribute user.
153 154 155 |
# File 'lib/fluent/plugin/out_irc.rb', line 153 def user @user end |
Instance Method Details
#join(channel) ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/fluent/plugin/out_irc.rb', line 202 def join(channel) IRCParser.(:join) do |m| m.channels = channel write m end @joined[channel] = true end |
#joined?(channel) ⇒ Boolean
198 199 200 |
# File 'lib/fluent/plugin/out_irc.rb', line 198 def joined?(channel) @joined[channel] end |
#on_connect ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/fluent/plugin/out_irc.rb', line 160 def on_connect if @password IRCParser.(:pass) do |m| m.password = @password write m end end IRCParser.(:nick) do |m| m.nick = @nick write m end IRCParser.(:user) do |m| m.user = @user m.postfix = @real write m end end |
#on_read(data) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/fluent/plugin/out_irc.rb', line 178 def on_read(data) data.each_line do |line| begin msg = IRCParser.parse(line) case msg.class.to_sym when :ping IRCParser.(:pong) do |m| m.target = msg.target m.body = msg.body write m end when :error log.warn "out_irc: an error occured. \"#{msg.error_message}\"" end rescue #TODO end end end |
#send_message(msg, channel) ⇒ Object
210 211 212 213 214 215 216 217 |
# File 'lib/fluent/plugin/out_irc.rb', line 210 def (msg, channel) join(channel) unless joined?(channel) IRCParser.(@command) do |m| m.target = channel m.body = msg write m end end |