ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-IRC3/lib/Net/IRC3/Util.pm
(Generate patch)

Comparing Net-IRC3/lib/Net/IRC3/Util.pm (file contents):
Revision 1.6 by elmex, Tue Jul 18 11:12:09 2006 UTC vs.
Revision 1.7 by elmex, Tue Jan 16 19:39:17 2007 UTC

2use strict; 2use strict;
3use Exporter; 3use Exporter;
4our @ISA = qw/Exporter/; 4our @ISA = qw/Exporter/;
5our @EXPORT_OK = 5our @EXPORT_OK =
6 qw(mk_msg parse_irc_msg split_prefix prefix_nick 6 qw(mk_msg parse_irc_msg split_prefix prefix_nick
7 decode_ctcp filter_ctcp_text_attr prefix_user prefix_host); 7 decode_ctcp filter_ctcp_text_attr prefix_user prefix_host
8 rfc_code_to_name);
8 9
9=head1 NAME 10=head1 NAME
10 11
11Net::IRC3::Util - Common utilities that help with IRC protocol handling 12Net::IRC3::Util - Common utilities that help with IRC protocol handling
12 13
13=head1 SYNOPSIS 14=head1 SYNOPSIS
14 15
15 use Net::IRC3 qw/parse_irc_msg mk_msg/; 16 use Net::IRC3 qw/parse_irc_msg mk_msg/;
16 17
17 my $msgdata = mk_msg (undef, PRIVMSG 18 my $msgdata = mk_msg (undef, PRIVMSG => "my hands glow!", "mcmanus");
18 19
19=head1 FUNCTIONS 20=head1 FUNCTIONS
20 21
21These are some utility functions that might come in handy when 22These are some utility functions that might come in handy when
22handling the IRC protocol. 23handling the IRC protocol.
225 return (split_prefix ($prfx))[2]; 226 return (split_prefix ($prfx))[2];
226} 227}
227 228
228=back 229=back
229 230
231=item B<rfc_code_to_name ($code)>
232
233This function is a interface to the internal mapping or numeric
234replies to the reply name in RFC 2812 (which you may also consult).
235
236C<$code> is returned if no name for C<$code> exists
237(as some server may extended the protocol).
238
239=cut
240
241our %RFC_NUMCODE_MAP = (
242 '001' => 'RPL_WELCOME',
243 '002' => 'RPL_YOURHOST',
244 '003' => 'RPL_CREATED',
245 '004' => 'RPL_MYINFO',
246 '005' => 'RPL_BOUNCE',
247 '200' => 'RPL_TRACELINK',
248 '201' => 'RPL_TRACECONNECTING',
249 '202' => 'RPL_TRACEHANDSHAKE',
250 '203' => 'RPL_TRACEUNKNOWN',
251 '204' => 'RPL_TRACEOPERATOR',
252 '205' => 'RPL_TRACEUSER',
253 '206' => 'RPL_TRACESERVER',
254 '207' => 'RPL_TRACESERVICE',
255 '208' => 'RPL_TRACENEWTYPE',
256 '209' => 'RPL_TRACECLASS',
257 '210' => 'RPL_TRACERECONNECT',
258 '211' => 'RPL_STATSLINKINFO',
259 '212' => 'RPL_STATSCOMMANDS',
260 '219' => 'RPL_ENDOFSTATS',
261 '221' => 'RPL_UMODEIS',
262 '233' => 'RPL_SERVICE',
263 '234' => 'RPL_SERVLIST',
264 '235' => 'RPL_SERVLISTEND',
265 '242' => 'RPL_STATSUPTIME',
266 '243' => 'RPL_STATSOLINE',
267 '250' => 'RPL_STATSDLINE',
268 '251' => 'RPL_LUSERCLIENT',
269 '252' => 'RPL_LUSEROP',
270 '253' => 'RPL_LUSERUNKNOWN',
271 '254' => 'RPL_LUSERCHANNELS',
272 '255' => 'RPL_LUSERME',
273 '256' => 'RPL_ADMINME',
274 '257' => 'RPL_ADMINLOC1',
275 '258' => 'RPL_ADMINLOC2',
276 '259' => 'RPL_ADMINEMAIL',
277 '261' => 'RPL_TRACELOG',
278 '262' => 'RPL_TRACEEND',
279 '263' => 'RPL_TRYAGAIN',
280 '301' => 'RPL_AWAY',
281 '302' => 'RPL_USERHOST',
282 '303' => 'RPL_ISON',
283 '305' => 'RPL_UNAWAY',
284 '306' => 'RPL_NOWAWAY',
285 '311' => 'RPL_WHOISUSER',
286 '312' => 'RPL_WHOISSERVER',
287 '313' => 'RPL_WHOISOPERATOR',
288 '314' => 'RPL_WHOWASUSER',
289 '315' => 'RPL_ENDOFWHO',
290 '317' => 'RPL_WHOISIDLE',
291 '318' => 'RPL_ENDOFWHOIS',
292 '319' => 'RPL_WHOISCHANNELS',
293 '321' => 'RPL_LISTSTART',
294 '322' => 'RPL_LIST',
295 '323' => 'RPL_LISTEND',
296 '324' => 'RPL_CHANNELMODEIS',
297 '325' => 'RPL_UNIQOPIS',
298 '331' => 'RPL_NOTOPIC',
299 '332' => 'RPL_TOPIC',
300 '341' => 'RPL_INVITING',
301 '342' => 'RPL_SUMMONING',
302 '346' => 'RPL_INVITELIST',
303 '347' => 'RPL_ENDOFINVITELIST',
304 '348' => 'RPL_EXCEPTLIST',
305 '349' => 'RPL_ENDOFEXCEPTLIST',
306 '351' => 'RPL_VERSION',
307 '352' => 'RPL_WHOREPLY',
308 '353' => 'RPL_NAMREPLY',
309 '364' => 'RPL_LINKS',
310 '365' => 'RPL_ENDOFLINKS',
311 '366' => 'RPL_ENDOFNAMES',
312 '367' => 'RPL_BANLIST',
313 '368' => 'RPL_ENDOFBANLIST',
314 '369' => 'RPL_ENDOFWHOWAS',
315 '371' => 'RPL_INFO',
316 '372' => 'RPL_MOTD',
317 '374' => 'RPL_ENDOFINFO',
318 '375' => 'RPL_MOTDSTART',
319 '376' => 'RPL_ENDOFMOTD',
320 '381' => 'RPL_YOUREOPER',
321 '382' => 'RPL_REHASHING',
322 '383' => 'RPL_YOURESERVICE',
323 '384' => 'RPL_MYPORTIS',
324 '391' => 'RPL_TIME',
325 '392' => 'RPL_USERSSTART',
326 '393' => 'RPL_USERS',
327 '394' => 'RPL_ENDOFUSERS',
328 '395' => 'RPL_NOUSERS',
329 '401' => 'ERR_NOSUCHNICK',
330 '402' => 'ERR_NOSUCHSERVER',
331 '403' => 'ERR_NOSUCHCHANNEL',
332 '404' => 'ERR_CANNOTSENDTOCHAN',
333 '405' => 'ERR_TOOMANYCHANNELS',
334 '406' => 'ERR_WASNOSUCHNICK',
335 '407' => 'ERR_TOOMANYTARGETS',
336 '408' => 'ERR_NOSUCHSERVICE',
337 '409' => 'ERR_NOORIGIN',
338 '411' => 'ERR_NORECIPIENT',
339 '412' => 'ERR_NOTEXTTOSEND',
340 '413' => 'ERR_NOTOPLEVEL',
341 '414' => 'ERR_WILDTOPLEVEL',
342 '415' => 'ERR_BADMASK',
343 '421' => 'ERR_UNKNOWNCOMMAND',
344 '422' => 'ERR_NOMOTD',
345 '423' => 'ERR_NOADMININFO',
346 '424' => 'ERR_FILEERROR',
347 '431' => 'ERR_NONICKNAMEGIVEN',
348 '432' => 'ERR_ERRONEUSNICKNAME',
349 '433' => 'ERR_NICKNAMEINUSE',
350 '436' => 'ERR_NICKCOLLISION',
351 '437' => 'ERR_UNAVAILRESOURCE',
352 '441' => 'ERR_USERNOTINCHANNEL',
353 '442' => 'ERR_NOTONCHANNEL',
354 '443' => 'ERR_USERONCHANNEL',
355 '444' => 'ERR_NOLOGIN',
356 '445' => 'ERR_SUMMONDISABLED',
357 '446' => 'ERR_USERSDISABLED',
358 '451' => 'ERR_NOTREGISTERED',
359 '461' => 'ERR_NEEDMOREPARAMS',
360 '462' => 'ERR_ALREADYREGISTRED',
361 '463' => 'ERR_NOPERMFORHOST',
362 '464' => 'ERR_PASSWDMISMATCH',
363 '465' => 'ERR_YOUREBANNEDCREEP',
364 '466' => 'ERR_YOUWILLBEBANNED',
365 '467' => 'ERR_KEYSET',
366 '471' => 'ERR_CHANNELISFULL',
367 '472' => 'ERR_UNKNOWNMODE',
368 '473' => 'ERR_INVITEONLYCHAN',
369 '474' => 'ERR_BANNEDFROMCHAN',
370 '475' => 'ERR_BADCHANNELKEY',
371 '476' => 'ERR_BADCHANMASK',
372 '477' => 'ERR_NOCHANMODES',
373 '478' => 'ERR_BANLISTFULL',
374 '481' => 'ERR_NOPRIVILEGES',
375 '482' => 'ERR_CHANOPRIVSNEEDED',
376 '483' => 'ERR_CANTKILLSERVER',
377 '484' => 'ERR_RESTRICTED',
378 '485' => 'ERR_UNIQOPPRIVSNEEDED',
379 '491' => 'ERR_NOOPERHOST',
380 '492' => 'ERR_NOSERVICEHOST',
381 '501' => 'ERR_UMODEUNKNOWNFLAG',
382 '502' => 'ERR_USERSDONTMATCH',
383);
384
385sub rfc_code_to_name {
386 my ($code) = @_;
387 return $RFC_NUMCODE_MAP{$code} || $code;
388}
389
230=head1 AUTHOR 390=head1 AUTHOR
231 391
232Robin Redeker, C<< <elmex@ta-sa.org> >> 392Robin Redeker, C<< <elmex@ta-sa.org> >>
233 393
234=head1 SEE ALSO 394=head1 SEE ALSO

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines