Bot::Jabbot::Modules - Jabbot Modules
This documentation provides an overview of writing new module for Bot::Jabbot.
package Bot::Jabbot::Module::Replier; use base qw(Bot::Jabbot::Module); use warnings; use strict; use AnyEvent; sub help { return "some help text"; } sub init { my ($self,$cl,$jid)=@_; $self->{timer} = AnyEvent->timer (after => 5, interval => 10, cb => sub { $self->timer($cl,$jid); }); return 0; } sub timer { #do something good } sub message { my ($self,$from,$body) = @_; return unless defined $body; return "wtf?"; } sub muc { my ($self,$from,$body) = @_; return unless defined $body; return "wtf?"; } 1;
Any Bot::Jabbot module should use Bot::Jabbot::Module as it's base
package Bot::Jabbot::Module::Replier; use base qw(Bot::Jabbot::Module);
or provide a new() and init() methods.
Called on bot start, usefull for defining a timers, getting data from db, etc. Should return 0 on success, or error text on error
reference to module object
An AnyEvent::XMPP::Connection assotiated with bot
Bot jid
If your module provides any private command, this method should return description on how to use it
If your module provides any MUC command, this method should return description on how to use it
called on MUC message
AnyEvent::XMPP::Ext::MUC::Message object
nick of bot in MUC room
reference to bot object
returns: reply text or undef.
called when user joins room
reference to object of joined user
AnyEvent::XMPP::Ext::MUC::Room object
called when user parts room (or banned, or kicked).
reference to object of parted user
called when someone changes conference subject.
AnyEvent::XMPP::Message object
AnyEvent::XMPP::Ext::MUC::User object
called on private message
You can (and should) use $self->loc() method for retrieving localized strings Translations should be placed into ModuleName/I18N/ subdirectory in the directory that contains module.
To install Bot::Jabbot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::Jabbot
CPAN shell
perl -MCPAN -e shell install Bot::Jabbot
For more information on module installation, please visit the detailed CPAN module installation guide.