Jo Walsh > Bot-JabberBot > Bot::JabberBot

Download:
Bot-JabberBot-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

    Bot::JabberBot - simple jabber bot base class 

SYNOPSIS ^

  use Bot::JabberBot;
  Bot::JabberBot->new( server => 'jabber.earth.li',
                       port => 5222,              # (default)
                       nick => 'jabberbot',
                       password => 'foo',
                       resource => 'foo')->run();

DESCRIPTION ^

a very simple Jabber bot base class, which shares interface with the Bot::BasicBot class for IRC bots. this allows me to take Bot::BasicBot subclasses and replace the base class with

    use base qw( Bot::JabberBot );

and they Just Work. also provides some jabber-specific features; the bot requests the Roster of jabberids whose presence it wants to know about; and when it it sent a jabber subscription request, it automatically accepts it and adds the requester to its roster.

METHODS ^

      new(%args);
         Creates a new instance of the class.  Name value pairs may be
passed which will have the same effect as calling the method of that name
with the value supplied.

      run();
         Runs the bot.  Hands the control over to the Jabber::Connection object 

      said({ who => 'test@jabber.org', body => 'foo'}) 
 
           This is the main method that you'll want to override in your sub-
class - it's the one called by default whenever someone sends a message.
You'll be passed a reference to a hash that contains these arguments:

            { who => [jabberid of message sender],
              body => [body text of message }

You should return what you want to say. This can either be a sim- ple string or a hashref that contains values that are compatible with say (just changing the body and returning the structure you were passed works very well.)

           Returning undef will cause nothing to be said.

      say({who => 'test@jabber.org', body => 'bar'})
  
           Say something to someone.

      roster();
           
           Returns an array ref of jabberids whose presence is registered with the bot.

     session();

           A session get-set is provided to store per-user session information.
Nothing is put in here by default.

BOT JABBER ACCOUNTS ^

To use a Bot::JabberBot you must register an account for it with a jabber server through a regular client, and set up transports to other IM accounts in this way. i thought of doing this automatically, but decided it would be spammy and might lead to bot abuse.

AUTHOR ^

    Jo Walsh  E<lt>jo@london.pm.orgE<gt>

CREDITS ^

    Simon Kent - maintainer of Bot::BasicBot
    Mark Fowler - original author of Bot::BasicBot
    DJ Adams - author of Jabber::Connection
    Tom Hukins - patched 0.02
    everyone on #bots and #pants

SEE ALSO ^

    <L>Bot::BasicBot
    <L>Jabber::Connection
    <L>Jabber::NodeFactory
syntax highlighting: