Parse QUIT and added event on_quit.
This commit is contained in:
1 parent
d3bb112d03
commit
28b697a3a5
2 files changed
+33
-1
No files matched your search
@@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log
|
||||
|
||||
3.0 Indev
|
||||
==================================================================
|
||||
* Added event on_quit.
|
||||
* Parse QUIT.
|
||||
* Added event on_part.
|
||||
* Parse PART.
|
||||
* Update chanusers on JOIN.
|
||||
|
||||
+31
-1
@@ -28,7 +28,8 @@ our %RAWC = (
|
||||
'NOTICE' => \¬ice,
|
||||
'PART' => \&part,
|
||||
'PRIVMSG' => \&privmsg,
|
||||
'TOPIC' => \&topic,
|
||||
'QUIT' => \&quit,
|
||||
'TOPIC' => \&topic,
|
||||
);
|
||||
|
||||
# Variables for various functions.
|
||||
@@ -42,6 +43,7 @@ API::Std::event_add("on_notice");
|
||||
API::Std::event_add("on_nick");
|
||||
API::Std::event_add("on_cprivmsg");
|
||||
API::Std::event_add("on_uprivmsg");
|
||||
API::Std::event_add("on_quit");
|
||||
API::Std::event_add("on_topic");
|
||||
|
||||
# Parse raw data.
|
||||
@@ -440,6 +442,34 @@ sub privmsg
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Parse: QUIT
|
||||
sub quit
|
||||
{
|
||||
my ($svr, @ex) = @_;
|
||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||
|
||||
# Delete the user from all channels.
|
||||
foreach my $ccu (keys %{ $chanusers{$svr} }) {
|
||||
delete $chanusers{$svr}{$ccu}{$src{nick}} if defined $chanusers{$svr}{$ccu}{$src{nick}};
|
||||
}
|
||||
|
||||
# Set $msg to the quit message.
|
||||
my $msg = 0;
|
||||
if (defined $ex[2]) {
|
||||
$msg = substr($ex[2], 1);
|
||||
if (defined $ex[3]) {
|
||||
for (my $i = 3; $i < scalar(@ex); $i++) {
|
||||
$msg .= " ".$ex[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Trigger on_quit.
|
||||
API::Std::event_run("on_quit", ($svr, %src, $msg));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Parse: TOPIC
|
||||
sub topic
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user