IRC::Toolkit::Numerics - Modern IRC numeric responses
use IRC::Toolkit::Numerics; ## Functional interface returns defaults: my $rpl = name_from_numeric( '001' ); # 'RPL_WELCOME' my $num = numeric_from_name( 'RPL_USERSDONTMATCH' ); # '502' ## OO interface allows (re)mapping numerics: my $numerics = IRC::Toolkit::Numerics->new; $numerics->get_name_for( '001' ); $numerics->get_numeric_for( 'RPL_WELCOME' ); $numerics->associate_numeric( '486' => 'ERR_HTMDISABLED' );
A pair of functions for translating IRC numerics into their "RPL" or "ERR" name and back again.
The included list attempts to be as complete as possible.
In cases where there is a conflict (typically between RFC2812, ircu, and hybrid/ratbox derivatives), modern ratbox labels are preferred, ratbox derivatives being the most prevalent across large networks.
In cases where that turns out not to be true, please send patches ;-)
Given a numeric, name_from_numeric returns its proper RPL name.
Given a RPL name, numeric_from_name returns its assigned command numeric.
my $numerics = IRC::Toolkit::Numerics->new;
Construct a new instance.
## A hybrid7 484 (overrides ratbox): $numerics->associate_numeric( '484' => 'ERR_RESTRICTED' );
Add or remap a numeric.
## RPL_WELCOME: my $name = $numerics->get_name_for('001'); ## ERR_CHANNELISFULL: $name = $numerics->get_name_for(471);
Retrieve the RPL/ERR label for a supplied numeric (or boolean false).
## 471: my $thisnum = $numerics->get_numeric_for('ERR_CHANNELISFULL');
Retrieve the numeric for a supplied RPL/ERR label (or boolean false).
my $hash = IRC::Toolkit::Numerics->export;
Exports a List::Objects::WithUtils::Hash mapping numerics to RPL/ERR names.
If called on a blessed instance (rather than as a class method), numerics remapped via "associate_numeric" are included in the exported hash.
Like "export", but returns the reversed hash (mapping RPL/ERR names to numerics).
Jon Portnoy <email@example.com>
Interface is based on IRC::Utils and helpful suggestions from <firstname.lastname@example.org>