NAME

Whatbot::Message - Wrapper class for whatbot message passing

SYNOPSIS

 use Whatbot::Message;
 
 my $message = Whatbot::Message->new(
	'from'    => $me,
	'to'      => 'a_user',
	'content' => 'test message'
 );

DESCRIPTION

Whatbot::Message is a container class for incoming and outgoing messages. Each whatbot component, when sending or receiving a message via a Whatbot::IO class will pass these objects, and messages sent through a Whatbot::Command is encouraged to use these objects. Messages sent without this class will be converted during the IO transaction.

PUBLIC ACCESSORS

from

User or entity the message is from

to

User or entity the message is to

content

Content of the message

timestamp

Timestamp of the message, in unix time.

is_private

Boolean (1/0), if the message was private or posted in a public channel.

is_direct

Boolean (1/0), if the message called the bot out by name

invisible

Boolean (1/0), if this message should not be processed by seen or other monitors.

me

String value of the bot's username.

origin

String containing the IO target signature, name:to. So, for an IRC server called irc.example.org, channel #foo, this would be IRC_irc.example.org:#foo.

METHODS

content_utf8()

Return message content as converted by encode_utf8.

is_private()

Determine if message is a private message, by checking if "to" matches "me".

reply( \%overrides )

Generate a Whatbot::Message in reply to the current message. If is_private is true, to will be set to the originator, otherwise, it will be set to the public context for public IO. Optionally handles an override hashref to preset fields, similar to the new constructor.

clone()

Return a new Whatbot::Message with the same content as the current message. References inside the object are reused, not duplicated.

LICENSE/COPYRIGHT

Be excellent to each other and party on, dudes.