Parse KICK, added event on_kick and added config option server:autorejoin for rejoining on kick.
This commit is contained in:
1 parent
28b697a3a5
commit
34fa7ae191
2 files changed
+54
No files matched your search
@@ -3,6 +3,9 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Added config option server:autorejoin for rejoining on kick.
|
||||||
|
* Added event on_kick.
|
||||||
|
* Parse KICK.
|
||||||
* Added event on_quit.
|
* Added event on_quit.
|
||||||
* Parse QUIT.
|
* Parse QUIT.
|
||||||
* Added event on_part.
|
* Added event on_part.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ our %RAWC = (
|
|||||||
'475' => \&num475,
|
'475' => \&num475,
|
||||||
'477' => \&num477,
|
'477' => \&num477,
|
||||||
'JOIN' => \&cjoin,
|
'JOIN' => \&cjoin,
|
||||||
|
'KICK' => \&kick,
|
||||||
'NICK' => \&nick,
|
'NICK' => \&nick,
|
||||||
'NOTICE' => \¬ice,
|
'NOTICE' => \¬ice,
|
||||||
'PART' => \&part,
|
'PART' => \&part,
|
||||||
@@ -38,6 +39,7 @@ our (%got_001, %botnick, %botchans, %csprefix, %chanusers);
|
|||||||
# Events.
|
# Events.
|
||||||
API::Std::event_add("on_rcjoin");
|
API::Std::event_add("on_rcjoin");
|
||||||
API::Std::event_add("on_ucjoin");
|
API::Std::event_add("on_ucjoin");
|
||||||
|
API::Std::event_add("on_kick");
|
||||||
API::Std::event_add("on_nick");
|
API::Std::event_add("on_nick");
|
||||||
API::Std::event_add("on_notice");
|
API::Std::event_add("on_notice");
|
||||||
API::Std::event_add("on_nick");
|
API::Std::event_add("on_nick");
|
||||||
@@ -330,6 +332,55 @@ sub cjoin
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse: KICK
|
||||||
|
sub kick
|
||||||
|
{
|
||||||
|
my ($svr, @ex) = @_;
|
||||||
|
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||||
|
|
||||||
|
# Update chanusers.
|
||||||
|
delete $chanusers{$svr}{$ex[2]}{$ex[3]} if defined $chanusers{$svr}{$ex[2]}{$ex[3]};
|
||||||
|
|
||||||
|
# Set $msg to the kick message.
|
||||||
|
my $msg = 0;
|
||||||
|
if (defined $ex[4]) {
|
||||||
|
$msg = substr($ex[4], 1);
|
||||||
|
if (defined $ex[5]) {
|
||||||
|
for (my $i = 5; $i < scalar(@ex); $i++) {
|
||||||
|
$msg .= " ".$ex[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if we were the ones kicked.
|
||||||
|
if (lc($ex[3]) eq lc($botnick{$svr}{nick})) {
|
||||||
|
# We were kicked!
|
||||||
|
|
||||||
|
# Delete channel from botchans.
|
||||||
|
for (my $i = 0; $i <= scalar(@{ $botchans{$svr} }); $i++) {
|
||||||
|
if (defined $botchans{$svr}[$i]) {
|
||||||
|
undef $botchans{$svr}[$i] if $botchans{$svr}[$i] eq $ex[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Log this horrible act.
|
||||||
|
API::Log::alog("I was kicked from ".$svr."/".$ex[2]." by ".$src{nick}."! Reason: ".$msg);
|
||||||
|
|
||||||
|
# Rejoin if we're told to in config.
|
||||||
|
if (conf_get("server:$svr:autorejoin")) {
|
||||||
|
if ((conf_get("server:$svr:autorejoin"))[0][0] eq 1) {
|
||||||
|
API::IRC::cjoin($svr, $ex[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# We weren't. Trigger on_kick.
|
||||||
|
API::Std::event_run("on_kick", ($svr, %src, $ex[2], $ex[3], $msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
# Parse: NICK
|
# Parse: NICK
|
||||||
sub nick
|
sub nick
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user