mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 16:46:26 +00:00
89 lines
3.0 KiB
Plaintext
89 lines
3.0 KiB
Plaintext
################################
|
|
# Services Login Module #
|
|
################################
|
|
|
|
package BotModules::ServicesLogin;
|
|
use vars qw(@ISA);
|
|
@ISA = qw(BotModules);
|
|
1;
|
|
|
|
# This module allows your mozbot to login to Network Services such as
|
|
# Nickserv, K9, Q on Quakenet, or X on Undernet.
|
|
#
|
|
# It works in two ways:
|
|
# * it logs in when the bot connects to IRC
|
|
# * it reauthenticates at regular intervals, to assure that mozbot is
|
|
# logged in at all times
|
|
#
|
|
# This module was originally written by Mohamed Elzakzoki
|
|
# <mhtawfiq@earthlink.net>.
|
|
|
|
|
|
sub RegisterConfig {
|
|
my $self = shift;
|
|
$self->SUPER::RegisterConfig(@_);
|
|
$self->registerVariables(
|
|
# [ name, save?, settable? ]
|
|
['loginCommand', 1, 1, undef],
|
|
['servicesNick', 1, 1, undef],
|
|
['delay', 1, 1, 900], # defaults to every 15 minutes
|
|
);
|
|
}
|
|
|
|
sub Schedule {
|
|
my $self = shift;
|
|
my ($event) = @_;
|
|
unless ($self->login($event)) {
|
|
$self->tellAdmin($event, 'To make me log in to a particular service, use the \'setupServicesLogin\' command, as in \'setupServicesLogin x@services.undernet.org login foobot p455w0rd\'. Type \'help setupServicesLogin\' for more information.');
|
|
}
|
|
$self->schedule($event, \$self->{'delay'}, -1, 'login');
|
|
$self->SUPER::Schedule($event);
|
|
}
|
|
|
|
sub Help {
|
|
my $self = shift;
|
|
my ($event) = @_;
|
|
return {
|
|
'' => 'The ServicesLogin module logs mozbot into services such as X on Undernet, Q on Quakenet, or NickServ or K9 on other networks. To setup the ServicesLogin command, use the setupServicesLogin command. See \'help setupServicesLogin\'.',
|
|
'setupServicesLogin' => 'The syntax of this command is \'setupServicesLogin <servicesNick> <loginCommand>\'. If the services nick is \'q@cserve.quakenet.org\', and the login command is \'auth mozbot mypass\', then you would type \'setupServicesLogin q@cserve.quakenet.org auth mozbot mypass\'. This will then cause mozbot to do: /msg q@cserve.quakenet.org auth mozbot mypass',
|
|
} if $self->isAdmin($event);
|
|
return {};
|
|
}
|
|
|
|
sub Scheduled {
|
|
my $self = shift;
|
|
my ($event, @data) = @_;
|
|
if ($data[0] eq 'login') {
|
|
$self->login($event);
|
|
} else {
|
|
$self->SUPER::Scheduled($event, @data);
|
|
}
|
|
}
|
|
|
|
sub Told {
|
|
my $self = shift;
|
|
my ($event, $message) = @_;
|
|
if ($message =~ /^\s*setup\s*services\s*login\s+(\S+)\s+(.+?)\s*$/osi) {
|
|
$self->{'servicesNick'} = $1;
|
|
$self->{'loginCommand'} = $2;
|
|
$self->saveConfig();
|
|
$self->say($event, "Ok, I'll contact $self->{'servicesNick'} regularly from now on.");
|
|
$self->login($event);
|
|
} else {
|
|
return $self->SUPER::Told(@_);
|
|
}
|
|
return 0; # we've dealt with it, no need to do anything else.
|
|
}
|
|
|
|
sub login {
|
|
my $self = shift;
|
|
my ($event) = @_;
|
|
if (defined $self->{'servicesNick'} and
|
|
defined $self->{'loginCommand'}) {
|
|
local $event->{'target'} = $self->{'servicesNick'};
|
|
$self->say($event, $self->{'loginCommand'});
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|