Module | Net::IRCOutputAPI |
In: |
lib/net/yail/output_api.rb
|
All output APIs live here. In most cases, an outgoing handler will get a call, but will not be able to stop the socket output since that‘s sorta an essential part of this whole library.
Output APIs dup incoming args before sending them off to handlers. This is a mechanism that I think could be done better, but I can‘t figure a good way to do it at the moment. The reason this is necessary is for a specific situation where a bot has an array of response messages, and needs to filter those messages. A call to "msg(messages[rand(10)])" with a handler on :outgoing_msg that does something like text.gsub!(‘a’, ’@’) (like a leetspeek filter) shouldn‘t destroy the original data in the messages array.
This could be left up to the programmer, but it seems like something that a library should own - protecting the programmer for having to remember that sort of crap, especially if the app is calling msg, act, ctcp, etc. in various ways from multiple points in the code.…
If a method exists in this module, and it isn‘t the raw method, chances are it‘s got a handler in the form of :outgoing_<method name>. I am hoping I document all of those in the main Net::YAIL code, but if I miss one, I apologize.
Calls :outgoing_ctcpreply handler, then uses notice method to send the CTCP text
I don‘t know what the server param is for, but it‘s in the RFC. If channel is blank, lists all visible, otherwise just lists the channel in question. Calls :outgoing_list and raw LIST command.
Calls :outgoing_part handler and then raw PART for leaving a given channel (with an optional message)
Sends a password to the server. This must be sent before NICK/USER. Calls :outgoing_pass and sends raw PASS command.
Calls :outgoing_privmsg handler, then sends a message (text) out to the given channel/user (target), and reports itself with the given string. This method shouldn‘t be called directly most of the time - just use msg, act, ctcp, etc.
This is sort of the central message output - everything that‘s based on PRIVMSG (messages, actions, other ctcp) uses this. Because these messages aren‘t insanely important, we actually buffer them instead of sending straight out to the channel. The output thread has to deal with sending these out.
Spits a raw string out to the server - in case a subclass wants to do something special on all output, please make all output go through this method. Don‘t use puts manually. I will kill violaters. Legally speaking, that is.
Identifies ourselves to the server. Calls :outgoing_user and sends raw USER command.