IM-Engine

 view release on metacpan or  search on metacpan

examples/dispatcher-plugin  view on Meta::CPAN


        # Just return a string and the plugin will know what to do
        return $result;
    };
};

IM::Engine->new(
    interface => {
        # Select any protocol you like. I enjoy CLI and REPL. :)
        protocol    => 'IRC',
        credentials => {
            server   => 'irc.perl.org',
            channels => ['#im-engine'],
            nick     => 'IM_Engine',
        },
    },
    plugins => [
        # Hook into Path::Dispatcher instead of defining an incoming_callback
        Dispatcher => {
            dispatcher => 'Rock::Paper::Scissors',
        },

examples/guessing-game  view on Meta::CPAN


    return 'Too low.' if $guess < $correct;
    return 'Too high.';
};

package main;

IM::Engine->new(
    interface => {
        protocol => 'IRC',
        credentials => {
            server   => 'irc.perl.org',
            channels => ['#im-engine'],
            nick     => 'Bisector',
        },
    },
    plugins => [
        'State::InMemory',
        Dispatcher => {
            dispatcher => 'Games::HiLo::Dispatcher',
        },

lib/IM/Engine.pm  view on Meta::CPAN


=head1 NAME

IM::Engine - The HTTP::Engine of instant messaging

=head1 SYNOPSIS

    IM::Engine->new(
        interface => {
            protocol => 'AIM',
            credentials => {
                screenname => '...',
                password   => '...',
            },
            incoming_callback => sub {
                my $incoming = shift;

                my $message = $incoming->plaintext;
                $message =~ tr[a-zA-Z][n-za-mN-ZA-M];

                return $incoming->reply($message);

lib/IM/Engine.pm  view on Meta::CPAN


IM::Engine currently understands the following protocols:

=head2 L<AIM|IM::Engine::Interface::AIM>

Talks AIM using L<Net::OSCAR>:

    IM::Engine->new(
        interface => {
            protocol => 'AIM',
            credentials => {
                screenname => 'foo',
                password   => '...',
            },
        },
        # ...
    );

=head2 L<Jabber|IM::Engine::Interface::Jabber>

Talks XMPP using L<AnyEvent::XMPP>:

    IM::Engine->new(
        interface => {
            protocol => 'Jabber',
            credentials => {
                jid      => 'foo@gchat.com',
                password => '...',
            },
        },
        # ...
    );

=head2 L<IRC|IM::Engine::Interface::IRC>

Talks IRC using L<AnyEvent::IRC>:

    IM::Engine->new(
        interface => {
            protocol => 'IRC',
            credentials => {
                server   => "irc.perl.org",
                port     => 6667,
                channels => ["#moose", "#im-engine"],
                nick     => "Boot",
            },
        },
        # ...
    );

There has been some concern about whether IRC is actually an IM protocol. I

lib/IM/Engine/Interface.pm  view on Meta::CPAN

use constant user_class => 'IM::Engine::User';

with 'IM::Engine::HasEngine';

has incoming_callback => (
    is        => 'rw',
    isa       => 'CodeRef',
    predicate => 'has_incoming_callback',
);

has credentials => (
    metaclass  => 'Collection::Hash',
    is         => 'ro',
    isa        => 'HashRef',
    default    => sub { {} },
    auto_deref => 1,
    provides   => {
        get    => 'credential',
        exists => 'has_credential',
    },
);

lib/IM/Engine/Interface/AIM.pm  view on Meta::CPAN


        $weakself->received_message($incoming);
    });

    $oscar->set_callback_signon_done(sub {
        $weakself->_set_signed_on(1);
    });

    weaken($weakself);

    $oscar->signon($self->credentials);

    return $oscar;
}

sub send_message {
    my $self     = shift;
    my $outgoing = shift;

    $self->_wait_until_signed_on unless $self->signed_on;



( run in 0.272 second using v1.01-cache-2.11-cpan-4d50c553e7e )