IM::Engine::Incoming - a message we have received


IM-Engine documentation Contained in the IM-Engine distribution.

Index


Code Index:

NAME

Top

IM::Engine::Incoming - a message we have received

ATTRIBUTES

Top

sender

An instance of IM::Engine::User which represents the sender of this incoming message.

message

See message in IM::Engine::Message.

plaintext

See plaintext in IM::Engine::Message.

METHODS

Top

reply

Constructs a IM::Engine::Outgoing message that represents a reply to this incoming message.

    my $outgoing = $incoming->reply("Sorry, I didn't understand.");

You can also pass in a hash of attributes for constructing the outgoing message.

SEE ALSO

Top

IM::Engine::Incoming::IRC
IM::Engine::Incoming::Jabber
IM::Engine::Outgoing
IM::Engine::Message (the superclass)

IM-Engine documentation Contained in the IM-Engine distribution.

package IM::Engine::Incoming;
use Moose;
use MooseX::StrictConstructor;

extends 'IM::Engine::Message';

use IM::Engine::Outgoing;
use constant _reply_class => 'IM::Engine::Outgoing';

has sender => (
    is       => 'ro',
    isa      => 'IM::Engine::User',
    required => 1,
);

sub reply {
    my $self = shift;
    my %args;

    if (@_ == 1) {
        %args = (message => $_[0]);
    }
    else {
        %args = @_;
    }

    Carp::carp("Incoming->reply constructs an Outgoing object for you; it does not automatically send it") if !defined(wantarray);

    my $outgoing = $self->_reply_class->new(
        $self->_contextual_reply_arguments,
        %args,
    );

    return $outgoing;
}

sub _contextual_reply_arguments {
    my $self = shift;

    return (
        incoming  => $self,
        recipient => $self->sender,
        inner,
    );
}

__PACKAGE__->meta->make_immutable;
no Moose;

1;

__END__