* Parse Numeric:438.

* Rewrote how we parse changing the bot's nick.
This commit is contained in:
Elijah Perrault committed 2011-01-21 16:28:39 -07:00
1 parent 159600b669
commit 27fbbd9208
3 files changed
+31 -7

No files matched your search

+8 -1
View File
@@ -18,6 +18,13 @@ sub cjoin
my ($svr, $chan) = @_;
Auto::socksnd($svr, "JOIN $chan");
unless (defined $Parser::IRC::botchans{$svr}) {
@{ $Parser::IRC::botchans{$svr} } = ($chan);
}
else {
push(@{ $Parser::IRC::botchans{$svr} }, $chan);
}
}
# Part a channel.
@@ -72,7 +79,7 @@ sub nick
Auto::socksnd($svr, "NICK $newnick");
$Parser::IRC::botnick{$svr} = $newnick;
$Parser::IRC::botnick{$svr}{newnick} = $newnick;
}
# Quit IRC.
+22 -6
View File
@@ -18,7 +18,7 @@ our %RAWC = (
);
# Variables for various functions.
our (%got_001, %botnick);
our (%got_001, %botnick, %botchans);
# Parse raw data.
sub _parse
@@ -91,6 +91,8 @@ sub num432
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
API::IRC::quit($svr, "An error occurred.");
}
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
}
# Parse: Numeric:433
@@ -99,8 +101,23 @@ sub num433
{
my ($svr, undef) = @_;
if (defined $botnick{$svr}) {
API::IRC::nick($svr, $botnick{$svr}."_");
if (defined $botnick{$svr}{newnick}) {
API::IRC::nick($svr, $botnick{$svr}{newnick}."_");
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
}
}
# Parse: Numeric:438
# Nick change too fast.
sub num438
{
my ($svr, @ex) = @_;
if (defined $botnick{$svr}{newnick}) {
API::Std::timer_add("num438_".$botnick{$svr}{newnick}, 1, $ex[11], sub {
API::IRC::nick($Parser::IRC::botnick{$svr}{newnick});
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
});
}
}
@@ -111,11 +128,10 @@ sub nick
my %src = API::IRC::usrc(substr($ex[0], 1));
# Check if this is coming from ourselves, meaning a forced nick change.
# Check if this is coming from ourselves.
if ($src{nick} eq $botnick{$svr}) {
# It is a forced nick change.
awarn(3, "Incoming NICK from myself?");
$botnick{$svr} = $ex[2];
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
}
}