Bug 215848: Cope with servers that don't like our IRC name. This is basically untested.
This commit is contained in:
Родитель
ae4b8465b6
Коммит
9bae650412
|
@ -349,6 +349,14 @@ are prompted for during initial startup. The interesting ones are:
|
|||
<foobot> user: green is good.
|
||||
* user patpats mozbot
|
||||
|
||||
simpleIRCNameServer -- If the value of this variable equals the
|
||||
name of the server, then the IRC Name sent to the server will be
|
||||
simplified so that it doesn't include the URI of the mozbot help
|
||||
files. This is usually dealt with automatically, but if you are
|
||||
having troubles connecting, you could try setting it. (It is set to
|
||||
the name of the server so that if you change servers, by default
|
||||
mozbot will use a complete IRC Name again.)
|
||||
|
||||
Changes to variables are usually immediately recorded in the
|
||||
configuration file and will be saved for the next time the bot is
|
||||
loaded.
|
||||
|
|
|
@ -193,6 +193,7 @@ my $variablepattern = '[-_:a-zA-Z0-9]+';
|
|||
my %users = ('admin' => &newPassword('password')); # default password for admin
|
||||
my %userFlags = ('admin' => 3); # bitmask; 0x1 = admin, 0x2 = delete user a soon as other admin authenticates
|
||||
my $helpline = 'see http://www.mozilla.org/projects/mozbot/'; # used in IRC name and in help
|
||||
my $serverRestrictsIRCNames = '';
|
||||
my @modulenames = ('General', 'Greeting', 'Infobot', 'Parrot');
|
||||
|
||||
# - which variables can be saved.
|
||||
|
@ -215,6 +216,7 @@ my @modulenames = ('General', 'Greeting', 'Infobot', 'Parrot');
|
|||
[\%userFlags, 'userFlags'], # usernames => bits
|
||||
[\$variablepattern, 'variablepattern'],
|
||||
[\$helpline, 'helpline'],
|
||||
[\$serverRestrictsIRCNames, 'simpleIRCNameServer'],
|
||||
[\$Mails::smtphost, 'smtphost'],
|
||||
);
|
||||
|
||||
|
@ -288,11 +290,16 @@ sub connect {
|
|||
|
||||
my ($bot, $mailed);
|
||||
|
||||
my $ircname = 'mozbot';
|
||||
if ($serverRestrictsIRCNames ne $server) {
|
||||
$ircname = "[$ircname] $helpline";
|
||||
}
|
||||
|
||||
until ($bot = $irc->newconn(
|
||||
Server => $server,
|
||||
Port => $port,
|
||||
Nick => $nicks[$nick],
|
||||
Ircname => "[mozbot] $helpline",
|
||||
Ircname => $ircname,
|
||||
Username => $USERNAME,
|
||||
LocalAddr => $localAddr,
|
||||
)) {
|
||||
|
@ -583,10 +590,18 @@ sub on_check_connect {
|
|||
|
||||
# if something nasty happens
|
||||
sub on_disconnected {
|
||||
my $self = shift;
|
||||
my ($self, $event) = @_;
|
||||
return if defined($self->{'__mozbot__shutdown'}); # HACK HACK HACK
|
||||
$self->{'__mozbot__shutdown'} = 1; # HACK HACK HACK
|
||||
&debug("eek! disconnected from network");
|
||||
my($reason) = $event->args;
|
||||
if ($reason eq 'Bad user info' and $serverRestrictsIRCNames ne $server) {
|
||||
# change our IRC name to something simpler by setting the flag
|
||||
$serverRestrictsIRCNames = $server;
|
||||
&Configuration::Save($cfgfile, &configStructure(\$serverRestrictsIRCNames));
|
||||
&debug('Hrm, $server didn\'t like our IRC name. Trying again with a simpler one.');
|
||||
} else {
|
||||
&debug("eek! disconnected from network: '$reason'");
|
||||
}
|
||||
foreach (@modules) { $_->unload(); }
|
||||
@modules = ();
|
||||
&connect();
|
||||
|
|
Загрузка…
Ссылка в новой задаче