NAME

IM::Engine::Plugin::State - Keep track of some state for each user

SYNOPSIS

IM::Engine->new(
    interface => {
        ...
        incoming_callback => sub {
            my $incoming = shift;
            my $user     = $incoming->sender;

            my $last_time = $user->get_state('last_time');
            my $now = time;
            $user->set_state(last_time => $now);

            if ($last_time) {
                return $incoming->reply("You last IMed me " . ($now - $last_time) . "s ago.");
            }
            else {
                return $incoming->reply("Hi, IM me again!");
            }
        },
    },
    plugins => ['State::InMemory'],
)->run;

DESCRIPTION

This module lets you store some state for each user. Right now the only backend is IM::Engine::Plugin::State::InMemory which seriously limits usability. But more will come. I just want something with a useful API that I can continue to build up.

AUTHOR

Shawn M Moore, sartak@gmail.com

SEE ALSO

IM::Engine

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.