* Parse Numeric:438.
* Rewrote how we parse changing the bot's nick.
This commit is contained in:
1 parent
159600b669
commit
27fbbd9208
3 files changed
+31
-7
No files matched your search
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Parse Numeric:438.
|
||||||
* Added timer_add() and timer_del() to API::Std for timers.
|
* Added timer_add() and timer_del() to API::Std for timers.
|
||||||
* Added events: on_sigterm, on_sigint and on_sighup.
|
* Added events: on_sigterm, on_sigint and on_sighup.
|
||||||
* Added event_add|del|run() and hook_add|del() to API::Std for
|
* Added event_add|del|run() and hook_add|del() to API::Std for
|
||||||
|
|||||||
+8
-1
@@ -18,6 +18,13 @@ sub cjoin
|
|||||||
my ($svr, $chan) = @_;
|
my ($svr, $chan) = @_;
|
||||||
|
|
||||||
Auto::socksnd($svr, "JOIN $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.
|
# Part a channel.
|
||||||
@@ -72,7 +79,7 @@ sub nick
|
|||||||
|
|
||||||
Auto::socksnd($svr, "NICK $newnick");
|
Auto::socksnd($svr, "NICK $newnick");
|
||||||
|
|
||||||
$Parser::IRC::botnick{$svr} = $newnick;
|
$Parser::IRC::botnick{$svr}{newnick} = $newnick;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Quit IRC.
|
# Quit IRC.
|
||||||
|
|||||||
+22
-6
@@ -18,7 +18,7 @@ our %RAWC = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Variables for various functions.
|
# Variables for various functions.
|
||||||
our (%got_001, %botnick);
|
our (%got_001, %botnick, %botchans);
|
||||||
|
|
||||||
# Parse raw data.
|
# Parse raw data.
|
||||||
sub _parse
|
sub _parse
|
||||||
@@ -91,6 +91,8 @@ sub num432
|
|||||||
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
|
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
|
||||||
API::IRC::quit($svr, "An error occurred.");
|
API::IRC::quit($svr, "An error occurred.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse: Numeric:433
|
# Parse: Numeric:433
|
||||||
@@ -99,8 +101,23 @@ sub num433
|
|||||||
{
|
{
|
||||||
my ($svr, undef) = @_;
|
my ($svr, undef) = @_;
|
||||||
|
|
||||||
if (defined $botnick{$svr}) {
|
if (defined $botnick{$svr}{newnick}) {
|
||||||
API::IRC::nick($svr, $botnick{$svr}."_");
|
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));
|
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}) {
|
if ($src{nick} eq $botnick{$svr}) {
|
||||||
# It is a forced nick change.
|
|
||||||
awarn(3, "Incoming NICK from myself?");
|
|
||||||
$botnick{$svr} = $ex[2];
|
$botnick{$svr} = $ex[2];
|
||||||
|
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user