Updating mozbot to version 2.0: changed to a more modular architecture, added support for multiple channels, added support for multiple nicks, generally cleaned up the code, etc. Uses some code and ideas from timeless and zach.
git-svn-id: svn://10.0.0.236/trunk@92921 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
51
mozilla/webtools/mozbot/BotModules/KeepAlive.bm
Normal file
51
mozilla/webtools/mozbot/BotModules/KeepAlive.bm
Normal file
@@ -0,0 +1,51 @@
|
||||
################################
|
||||
# KeepAlive Module #
|
||||
################################
|
||||
|
||||
package BotModules::KeepAlive;
|
||||
use vars qw(@ISA);
|
||||
@ISA = qw(BotModules);
|
||||
1;
|
||||
|
||||
# RegisterConfig - Called when initialised, should call registerVariables
|
||||
sub RegisterConfig {
|
||||
my $self = shift;
|
||||
$self->SUPER::RegisterConfig(@_);
|
||||
$self->registerVariables(
|
||||
# [ name, save?, settable? ]
|
||||
['delay', 1, 1, 20],
|
||||
['string', 1, 1, 'ping'],
|
||||
['target', 1, 1, '#spam'],
|
||||
);
|
||||
}
|
||||
|
||||
# Schedule - called when bot connects to a server, to install any schedulers
|
||||
# use $self->schedule($event, $delay, $times, $data)
|
||||
# where $times is 1 for a single event, -1 for recurring events,
|
||||
# and a +ve number for an event that occurs that many times.
|
||||
sub Schedule {
|
||||
my $self = shift;
|
||||
my ($event) = @_;
|
||||
$self->schedule($event, \$self->{'delay'}, -1, 'keepalive');
|
||||
$self->SUPER::Schedule($event);
|
||||
}
|
||||
|
||||
sub Help {
|
||||
my $self = shift;
|
||||
my ($event) = @_;
|
||||
return {
|
||||
'' => 'This is a simple keep-alive module, it regularly sends text out. This has been known to help with network lag.',
|
||||
} if $self->isAdmin($event);
|
||||
return {};
|
||||
}
|
||||
|
||||
sub Scheduled {
|
||||
my $self = shift;
|
||||
my ($event, @data) = @_;
|
||||
if ($data[0] eq 'keepalive') {
|
||||
local $event->{'target'} = $self->{'target'};
|
||||
$self->say($event, $self->{'string'});
|
||||
} else {
|
||||
$self->SUPER::Scheduled($event, @data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user