IRC::Message::Object - Incoming or outgoing IRC events
## Feed me some parameters: my $event = IRC::Message::Object->new( command => '001', prefix => ':some.server.org', params => [ 'user', 'Welcome to IRC' ], ); ## ... or import and use the 'ircmsg()' shortcut: use IRC::Message::Object 'ircmsg'; my $event = ircmsg( command => '001', prefix => ':some.server.org', params => [ 'user', 'Welcome to IRC' ], ); ## ... or take a raw IRC line (and parse it): $event = ircmsg( raw_line => ':some.server.org 001 user :Welcome to IRC' ); ## ... or feed from POE::Filter::IRCD or POE::Filter::IRCv3: $event = ircmsg( %$ref_from_filter ); ## ... retrieve useful bits later (see Methods): my $cmd = $event->command; my $line = $event->raw_line; if ($event->has_tag('monkeys')) { ... }
These objects represent incoming or outgoing IRC messages (events); they can be created from either named parameters or a raw IRC line and provide accessors with automatic parsing magic.
Create a new IRC::Message::Object; shortcut for IRC::Message::Object->new.
IRC::Message::Object->new
This module uses Exporter::Tiny, so you can rename the exported constructor if you like:
use IRC::Message::Object ircmsg => { -as => 'irc_ev' };
The raw IRC line. The line is generated via the current "filter" if the message object wasn't constructed with one.
predicate: has_raw_line
has_raw_line
The parsed command received.
Note that if the command is set at construction time, no case-folding takes place. However, specifying a raw_line at construction feeds POE::Filter::IRCv3, which will uppercase commands.
command
raw_line
predicate: has_command
has_command
ARRAY of parameters.
The origin prefix.
predicate: has_prefix
has_prefix
Set to a boolean false value at construction time to instruct POE::Filter::IRCv3 not to always prefix the last argument with a colon.
Defaults to true.
Can be used to change the POE::Filter used to transform a raw line into a HASH and vice-versa.
Defaults to a POE::Filter::IRCv3 instance.
Retrieve a specific IRCv3.2 message tag's value.
This only works for tags with a defined value; see "has_tag" to discover if a tag exists.
Takes a tag identifier; returns true if the tag exists.
This is useful for finding out about tags that have no defined value.
Returns true if there are tags present.
IRCv3.2 message tags, as a HASH of key-value pairs.
IRCv3.2 message tags, as an ARRAY of tags in the form of 'key=value'
IRCv3.2 message tags as a specification-compliant string.
Truncates the raw line to 510 characters, excluding message tags (per the specification), and returns a new IRC::Message::Object.
Jon Portnoy <avenj@cobaltirc.org>
To install IRC::Toolkit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IRC::Toolkit
CPAN shell
perl -MCPAN -e shell install IRC::Toolkit
For more information on module installation, please visit the detailed CPAN module installation guide.