NAME

IRC::Message::Object - Incoming or outgoing IRC events

SYNOPSIS

## Feed me some parameters:
my $event = IRC::Message::Object->new(
  command  => '001',
  prefix   => ':some.server.org',
  params   => [ 'user', 'Welcome to IRC' ],
);

## ... or use the 'ircmsg()' shortcut:
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')) {
  ...
}

DESCRIPTION

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.

Functions

ircmsg

Create a new IRC::Message::Object; shortcut for 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' };

Attributes and Methods

raw_line

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

command

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.

params

A List::Objects::WithUtils::Array containing the parameters attached to the message.

predicate: has_params

prefix

The origin prefix.

predicate: has_prefix

colonify

Passed through to "colonify" in POE::Filter::IRCv3; see the POE::Filter::IRCv3 documentation for details.

Defaults to true.

filter

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 with colonify => 0 set.

get_tag

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.

has_tag

Takes a tag identifier; returns true if the tag exists.

This is useful for finding out about tags that have no defined value.

has_tags

Returns true if there are tags present.

tags

IRCv3.2 message tags, as a List::Objects::WithUtils::Hash of key-value pairs.

tags_as_array

IRCv3.2 message tags, as a List::Objects::WithUtils::Array of tags in the form of 'key=value'

tags_as_string

IRCv3.2 message tags as a specification-compliant string.

truncate

Truncates the raw line to 510 characters, excluding message tags (per the specification), and returns a new IRC::Message::Object.

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>