NAME

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

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);
        },
    },
)->run;

DESCRIPTION

IM::Engine abstracts away the details of talking through different IM services. A Jabber bot will be essentially the same as an AIM bot, so IM::Engine facilitates switching between these different services.

It is currently alpha quality with serious features missing and is rife with horrible bugs. I'm releasing it under the "release early, release often" doctrine. Backwards compatibility may be broken in subsequent releases.

In particular, I am likely to move IM::Engine::Interface::AIM, IM::Engine::Interface::Jabber, and IM::Engine::Interface::IRC into their own distributions, since they have their own dependencies.

PROTOCOLS

IM::Engine currently understands the following protocols:

AIM

Talks AIM using Net::OSCAR:

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

Jabber

Talks XMPP using AnyEvent::XMPP:

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

IRC

Talks IRC using 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 certainly consider private messages to be IM-ish. For some bots, joining regular human-infested channels would also make sense. Bots that just respond to chatters (which is most, if not all, of what purl does) make sense outside of the context of IRC, so that is the use case I am targetting.

REPL

Opens up a shell where every line of input is an IM. Responses will be printed to standard output. Handy for testing.

IM::Engine->new(
    interface => {
        protocol => 'REPL',
    },
    # ...
);

CLI

Pass your IM as command-line arguments. Your response will be printed to standard output. Handy for testing but could also be distributed as a useful script (I want this for Hiveminder's IM interface :))

IM::Engine->new(
    interface => {
        protocol => 'CLI',
    },
    # ...
);

AUTHOR

Shawn M Moore, sartak@gmail.com

SEE ALSO

HTTP::Engine

The inspiration for the initial design

IM::Engine::Plugin::Dispatcher

Uses Path::Dispatcher to provide sugary IM dispatch

IM::Engine::Plugin::State

Provides state management methods on IM::Engine::Users

IM::Engine::Plugin::MultiCommand

Allows multiple commands to be run in one IM (builds on IM::Engine::Plugin::Dispatcher)

COPYRIGHT AND LICENSE

Copyright 2009 Shawn M Moore.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.