|
@@ -8,12 +8,12 @@ Pisg::Common - some common functions of pisg.
|
|
|
|
|
|
|
|
use Exporter;
|
|
use Exporter;
|
|
|
@ISA = ('Exporter');
|
|
@ISA = ('Exporter');
|
|
|
-@EXPORT = qw(add_alias add_aliaswild add_ignore is_ignored find_alias match_url match_email htmlentities);
|
|
|
|
|
|
|
+@EXPORT = qw(add_alias add_aliaswild add_ignore add_url_ignore is_ignored url_is_ignored find_alias match_url match_email htmlentities);
|
|
|
|
|
|
|
|
use strict;
|
|
use strict;
|
|
|
$^W = 1;
|
|
$^W = 1;
|
|
|
|
|
|
|
|
-my (%aliases, %aliaswilds, %ignored, %aliasseen);
|
|
|
|
|
|
|
+my (%aliases, %aliaswilds, %ignored, %aliasseen, %ignored_urls);
|
|
|
|
|
|
|
|
# add_alias assumes that the first argument is the true nick and the second is
|
|
# add_alias assumes that the first argument is the true nick and the second is
|
|
|
# the alias, but will accomidate other arrangements if necessary.
|
|
# the alias, but will accomidate other arrangements if necessary.
|
|
@@ -60,11 +60,25 @@ sub add_ignore
|
|
|
sub is_ignored
|
|
sub is_ignored
|
|
|
{
|
|
{
|
|
|
my $nick = shift;
|
|
my $nick = shift;
|
|
|
- if ($ignored{$nick} || $ignored{find_alias($nick)}) {
|
|
|
|
|
|
|
+ if ($ignored{$nick} or $ignored{find_alias($nick)}) {
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+sub url_is_ignored
|
|
|
|
|
+{
|
|
|
|
|
+ my $url = shift;
|
|
|
|
|
+ if ($ignored_urls{$url}) {
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+sub add_url_ignore
|
|
|
|
|
+{
|
|
|
|
|
+ my $url = shift;
|
|
|
|
|
+ $ignored_urls{$url} = 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
# For efficiency reasons, find_alias() caches aliases when it finds them,
|
|
# For efficiency reasons, find_alias() caches aliases when it finds them,
|
|
|
# because the regexp search through %aliaswilds is *really* expensive.
|
|
# because the regexp search through %aliaswilds is *really* expensive.
|
|
|
# %aliasseen is used to mark nicks for which nothing matches--we can't add
|
|
# %aliasseen is used to mark nicks for which nothing matches--we can't add
|
|
@@ -78,7 +92,7 @@ sub find_alias
|
|
|
if ($aliases{$lcnick}) {
|
|
if ($aliases{$lcnick}) {
|
|
|
return $aliases{$lcnick};
|
|
return $aliases{$lcnick};
|
|
|
} elsif ($aliasseen{$lcnick}) {
|
|
} elsif ($aliasseen{$lcnick}) {
|
|
|
- return $aliasseen{$lcnick};
|
|
|
|
|
|
|
+ return $aliasseen{$lcnick};
|
|
|
} else {
|
|
} else {
|
|
|
foreach (keys %aliaswilds) {
|
|
foreach (keys %aliaswilds) {
|
|
|
if ($nick =~ /^$_$/i) {
|
|
if ($nick =~ /^$_$/i) {
|