Added events on_ucjoin, on_rcjoin and on_nick.
This commit is contained in:
1 parent
97361c3ec1
commit
dda0b7785b
2 files changed
+20
-3
No files matched your search
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Added events on_ucjoin, on_rcjoin and on_nick.
|
||||||
* Parse numerics 465, 471-475 and 477.
|
* Parse numerics 465, 471-475 and 477.
|
||||||
* Added an optional @args onto event_run() for sending @args
|
* Added an optional @args onto event_run() for sending @args
|
||||||
to the subs that have hooked onto the event.
|
to the subs that have hooked onto the event.
|
||||||
|
|||||||
+19
-3
@@ -28,6 +28,11 @@ our %RAWC = (
|
|||||||
# Variables for various functions.
|
# Variables for various functions.
|
||||||
our (%got_001, %botnick, %botchans);
|
our (%got_001, %botnick, %botchans);
|
||||||
|
|
||||||
|
# Events.
|
||||||
|
API::Std::event_add("on_rcjoin");
|
||||||
|
API::Std::event_add("on_ucjoin");
|
||||||
|
API::Std::event_add("on_nick");
|
||||||
|
|
||||||
# Parse raw data.
|
# Parse raw data.
|
||||||
sub _parse
|
sub _parse
|
||||||
{
|
{
|
||||||
@@ -191,26 +196,37 @@ sub cjoin
|
|||||||
|
|
||||||
# Check if this is coming from ourselves.
|
# Check if this is coming from ourselves.
|
||||||
if ($src{nick} eq $botnick{$svr}) {
|
if ($src{nick} eq $botnick{$svr}) {
|
||||||
|
# It is. Add channel to array and trigger on_ucjoin.
|
||||||
unless (defined $botchans{$svr}) {
|
unless (defined $botchans{$svr}) {
|
||||||
@{ $botchans{$svr} } = (substr($ex[2], 1));
|
@{ $botchans{$svr} } = (substr($ex[2], 1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push(@{ $botchans{$svr} }, substr($ex[2], 1));
|
push(@{ $botchans{$svr} }, substr($ex[2], 1));
|
||||||
}
|
}
|
||||||
|
API::Std::event_run("on_ucjoin", (substr($ex[2], 1)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# It isn't. Trigger on_rcjoin.
|
||||||
|
API::Std::event_run("on_rcjoin", (%src, substr($ex[2], 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse: NICK
|
# Parse: NICK
|
||||||
sub nick
|
sub nick
|
||||||
{
|
{
|
||||||
my ($svr, @ex) = @_;
|
my ($svr, ($uex, undef, $nex)) = @_;
|
||||||
|
|
||||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
my %src = API::IRC::usrc(substr($uex, 1));
|
||||||
|
|
||||||
# Check if this is coming from ourselves.
|
# Check if this is coming from ourselves.
|
||||||
if ($src{nick} eq $botnick{$svr}) {
|
if ($src{nick} eq $botnick{$svr}) {
|
||||||
$botnick{$svr} = $ex[2];
|
# It is. Update bot nick hash.
|
||||||
|
$botnick{$svr} = $nex;
|
||||||
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
|
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# It isn't. Trigger on_nick.
|
||||||
|
API::Std::event_run("on_nick", (%src, $nex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user