AnyEvent::IRC::Util(3pm) | User Contributed Perl Documentation | AnyEvent::IRC::Util(3pm) |
AnyEvent::IRC::Util - Common utilities that help with IRC protocol handling
use AnyEvent::IRC::Util qw/parse_irc_msg mk_msg/; my $msgdata = mk_msg (undef, PRIVMSG => "mcmanus", "my hands glow!");
These are some utility functions that might come in handy when handling the IRC protocol.
You can export these with eg.:
use AnyEvent::IRC::Util qw/parse_irc_msg/;
It returns a hash which has the following entries:
:<prefix> <command> <params> :<trail>
Please refer to RFC 1459 how IRC messages normally look like.
The prefix will be omitted if they are "undef".
Please note that only the last parameter may contain spaces, and if it contains spaces it will be quoted as the trailing part of the IRC message.
NOTE: The trailing "\015\012" is NOT added by this function!
EXAMPLES:
mk_msg (undef, "PRIVMSG", "magnus", "you suck!"); # will return: "PRIVMSG magnus :you suck!" mk_msg (undef, "PRIVMSG", "magnus", "Hi!"); # will return: "PRIVMSG magnus :Hi!" mk_msg (undef, "JOIN", "#test"); # will return: "JOIN #test"
It will first unescape the lower layer, extract CTCP messages and then return a list with two elements: the line without the CTCP messages and an array reference which contains array references of CTCP messages. Those CTCP message array references will have the CTCP message tag as first element (eg. "VERSION") and the rest of the CTCP message as the second element.
All parts of the message will be concatenated and lowlevel quoted. That means you can embed _any_ character from 0 to 255 in this message (that's what the lowlevel quoting allows).
$prefix can also be a hash like it is returned by "parse_irc_msg".
$prefix can also be a hash like it is returned by "parse_irc_msg".
$prefix can also be a hash like it is returned by "parse_irc_msg".
$prefix can also be a hash like it is returned by "parse_irc_msg".
$code is returned if no name for $code exists (as some server may extended the protocol).
This function takes care that your characters are not garbled.
Robin Redeker, "<elmex@ta-sa.org>"
Internet Relay Chat Client To Client Protocol from February 2, 1997 http://www.invlogic.com/irc/ctcp.html
RFC 1459 - Internet Relay Chat: Client Protocol
Copyright 2006-2009 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-06-06 | perl v5.34.0 |