NAME

Infobot::Message - Encapsulate incoming queries

SYNOPSIS

 use Infobot::Message;

 my $message = Infobot::Message->new();

 # These all become available as accessors

 $message->init(
		addressed => 1,
		conduit   => $irc_conduit,
		context   => { channel => '#perl' },
		name      => 'sheriff',
		message   => 'Hey purl!',
		public    => 1,
		nick      => 'purl',
		printable => '[#perl/sheriff] purl: Hey purl!',
 );

 my $id = $message->id;

 $message->say( "Right back at ya, ", $message->name );

 $self->stash('pipeline')->process( $message );

ATTRIBUTES

These are the attributes a conduit must pass to init, and which other plugins that use Infobot::Message can rely on being set.

addressed

If we were specifically spoken to by the user. In situations where the bot is the only possible recipient (say a console conduit), then this should be set to one regardless.

conduit

The conduit object which created the message.

context

Any conduit-specific information (hashref). This should not be relied upon in any place other than the conduit itself - the default for any value you put in should be 0/undef. So, the IRC conduit uses an 'addressing' value in here, which specifies if the current channel requires addressing (set up in the config). It defaults to 0, so any plugin that doesn't deal with IRC doesn't need to care about it.

channel and addressing are the only keys that are currently suggested for use outside of the conduit itself, but PLEASE programme defensively here, and don't rely on ANY value being here...

message

The text of the message itself

name

The name (human-readable) of the user talking to us

nick

Our name - please default to the value of $self-stash('config')->{alias}> if your conduit doesn't have this concept.

printable

A nice, loggable text representation of the message text plus some context - for IRC, we use channel name and nick and the message, nicely formatted in one string.

public

If the comment was made in a 'public' place (IRC channel, for example).

METHODS

id

Returns a unique(ish) ID for the message

ATTRIBUTES...

All the above attributes are also read-only accessors...

init

Accepts a list of the attributes as described above. Returns 1 on success.

say

Prints the message in the appropriate conduit, having checked addressing and done some logging