Skip to content

Commit b4ba7ab

Browse files
authored
Merge pull request #888 from zelgomer/zmartfilter
Update zmartfilter.pl to v1.01
2 parents 95fe744 + 8a3c496 commit b4ba7ab

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

scripts/zmartfilter.pl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use Irssi;
33
use vars qw($VERSION %IRSSI);
44

5-
$VERSION = "1.00";
5+
$VERSION = "1.01";
66
%IRSSI = (
77
name => "zmartfilter",
88
description => "smartfilter.pl reimagined, optimized for unusually flakey networks such as IRC over I2P",
@@ -169,10 +169,15 @@ sub print_text {
169169
return;
170170
}
171171

172-
my ($level, @nicks) = $dest->{level};
172+
my ($level, @nicks, %addresses) = $dest->{level};
173173
if ($level & (MSGLEVEL_JOINS | MSGLEVEL_PARTS | MSGLEVEL_QUITS)) {
174-
if ($stripped =~ /([^ ]+) \[.+\] has (joined|left|quit)/) {
174+
if ($stripped =~ /([^ ]+) \[([^]]+)\] has (joined|left|quit)/) {
175175
@nicks = ($1);
176+
# this nick may have just parted or quit, in which case
177+
# we can't rely on the channel->nick->address lookup,
178+
# so we need to use the address in the message text
179+
# when we can
180+
$addresses{$1} = $2;
176181
}
177182
} elsif ($level & MSGLEVEL_NICKS) {
178183
if ($stripped =~ /[^ ]+ is now known as ([^ ]+)/) {
@@ -197,11 +202,14 @@ sub print_text {
197202
# it's text that relates to me
198203
return;
199204
}
200-
my $address = $server->channel_find($target);
201-
$address = $address->nick_find($nick);
202-
$address = $address->{host};
205+
my $address = $addresses{$nick};
203206
if (!$address) {
204-
next;
207+
$address = $server->channel_find($target);
208+
$address = $address->nick_find($nick);
209+
$address = $address->{host};
210+
if (!$address) {
211+
next;
212+
}
205213
}
206214
if ($server->mask_match_address('*!*@services.*', "", $address)) {
207215
# relates to network services

0 commit comments

Comments
 (0)