1 ################################
2 # Services Login Module #
3 ################################
5 package BotModules::ServicesLogin;
10 # This module allows your mozbot to login to Network Services such as
11 # Nickserv, K9, Q on Quakenet, or X on Undernet.
13 # It works in two ways:
14 # * it logs in when the bot connects to IRC
15 # * it reauthenticates at regular intervals, to assure that mozbot is
16 # logged in at all times
18 # This module was originally written by Mohamed Elzakzoki
19 # <mhtawfiq@earthlink.net>.
24 $self->SUPER::RegisterConfig(@_);
25 $self->registerVariables(
26 # [ name, save?, settable? ]
27 ['loginCommand', 1, 1, undef],
28 ['servicesNick', 1, 1, undef],
29 ['delay', 1, 1, 900], # defaults to every 15 minutes
36 unless ($self->login($event)) {
37 $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.');
39 $self->schedule($event, \$self->{'delay'}, -1, 'login');
40 $self->SUPER::Schedule($event);
47 '' => '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\'.',
48 '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',
49 } if $self->isAdmin($event);
55 my ($event, @data) = @_;
56 if ($data[0] eq 'login') {
59 $self->SUPER::Scheduled($event, @data);
65 my ($event, $message) = @_;
66 if ($message =~ /^\s*setup\s*services\s*login\s+(\S+)\s+(.+?)\s*$/osi) {
67 $self->{'servicesNick'} = $1;
68 $self->{'loginCommand'} = $2;
70 $self->say($event, "Ok, I'll contact $self->{'servicesNick'} regularly from now on.");
73 return $self->SUPER::Told(@_);
75 return 0; # we've dealt with it, no need to do anything else.
81 if (defined $self->{'servicesNick'} and
82 defined $self->{'loginCommand'}) {
83 local $event->{'target'} = $self->{'servicesNick'};
84 $self->privsay($event, $self->{'loginCommand'});