summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-default/commands.xml15
-rw-r--r--config-default/rules.xml1
-rw-r--r--lib/ASM/Classes.pm20
3 files changed, 34 insertions, 2 deletions
diff --git a/config-default/commands.xml b/config-default/commands.xml
index 463b2e6..38c2d99 100644
--- a/config-default/commands.xml
+++ b/config-default/commands.xml
@@ -649,7 +649,17 @@
my $str = lc $1;
use String::CRC32;
my $id = sprintf("%08x", crc32($str));
- $::blacklist->{string}->{$id} = { "content" => $str, "setby" => $event->nick, "settime" => strftime('%F', gmtime) };
+ $::blacklist->{string}->{$id} = { "content" => $str, "type" => "string", "setby" => $event->nick, "settime" => strftime('%F', gmtime) };
+ ASM::XML->writeBlacklist();
+ $conn->privmsg($event->replyto, "$str blacklisted with id $id, please use ;blreason $id reasonGoesHere to set a reason");
+ ]]>
+ </command>
+ <command cmd="^;blacklistpcre (.*)" flag="a">
+ <![CDATA[
+ my $str = lc $1;
+ use String::CRC32;
+ my $id = sprintf("%08x", crc32($str));
+ $::blacklist->{string}->{$id} = { "content" => $str, "type" => "pcre", "setby" => $event->nick, "settime" => strftime('%F', gmtime) };
ASM::XML->writeBlacklist();
$conn->privmsg($event->replyto, "$str blacklisted with id $id, please use ;blreason $id reasonGoesHere to set a reason");
]]>
@@ -713,8 +723,9 @@
my $setby = $::blacklist->{string}->{$id}->{setby};
my $settime = $::blacklist->{string}->{$id}->{settime};
my $reason = $::blacklist->{string}->{$id}->{reason};
+ my $type = $::blacklist->{string}->{$id}->{type};
$reason = 'none ever provided' unless defined($reason);
- $conn->privmsg($event->nick, "'$content' blacklisted by $setby on $settime with reason $reason");
+ $conn->privmsg($event->nick, "'$content' $type blacklisted by $setby on $settime with reason $reason");
if ($event->{to}->[0] =~ /^#/) {
$conn->privmsg($event->replyto, "Info on blacklist ID $id sent via PM");
}
diff --git a/config-default/rules.xml b/config-default/rules.xml
index af49a16..19fe2be 100644
--- a/config-default/rules.xml
+++ b/config-default/rules.xml
@@ -8,6 +8,7 @@
<event id="autoremove" class="re" reason="on chanserv autoremove" risk="info" type="part">^requested by ChanServ</event>
<event id="blacklist" class="strbl" reason="sending message containing blacklisted content" risk="low" type="public,part,quit,caction">blah</event>
<event id="blacklist2" class="strblnew" reason="blacklist $xresult" risk="medium" type="public,part,quit,caction">blah</event>
+ <event id="blacklistpcre" class="strblpcre" reason="pcre blacklist $xresult" risk="medium" type="public,part,quit,caction">blah</event>
<event id="ctcp-dcc" class="re" reason="ctcp-dcc" risk="high" type="cdcc">.*</event>
<event id="ctcp-ping" class="re" reason="channel-wide CTCP PING" risk="medium" type="cping">.*</event>
<event id="ctcp-version" class="re" reason="channel-wide CTCP VERSION" risk="medium" type="cversion">.*</event>
diff --git a/lib/ASM/Classes.pm b/lib/ASM/Classes.pm
index 8c874b5..325b71d 100644
--- a/lib/ASM/Classes.pm
+++ b/lib/ASM/Classes.pm
@@ -16,6 +16,7 @@ sub new
my $tbl = {
"strbl" => \&strbl,
"strblnew" => \&strblnew,
+ "strblpcre" => \&strblpcre,
"dnsbl" => \&dnsbl,
"floodqueue" => \&floodqueue,
"floodqueue2" => \&floodqueue2,
@@ -395,6 +396,7 @@ sub strblnew {
my ($chk, $xid, $event, $chan) = @_;
my $match = lc $event->{args}->[0];
foreach my $id (keys %{$::blacklist->{string}}) {
+ next unless $::blacklist->{string}->{$id}->{type} eq "string";
my $line = lc $::blacklist->{string}->{$id}->{content};
my $idx = index $match, $line;
if ( $idx != -1 ) {
@@ -408,6 +410,24 @@ sub strblnew {
return 0;
}
+sub strblpcre {
+ my ($chk, $xid, $event, $chan) = @_;
+ my $match = lc $event->{args}->[0];
+ foreach my $id (keys %{$::blacklist->{string}}) {
+ next unless $::blacklist->{string}->{$id}->{type} eq "pcre";
+ my $line = lc $::blacklist->{string}->{$id}->{content};
+ my $idx = index $match, $line;
+ if ( $match =~ /$line/ ) {
+ my $setby = $::blacklist->{string}->{$id}->{setby};
+ $setby = substr($setby, 0, 1) . "\x02\x02" . substr($setby, 1);
+ return defined($::blacklist->{string}->{$id}->{reason}) ?
+ "id $id added by $setby because $::blacklist->{string}->{$id}->{reason}" :
+ "id $id added by $setby for no reason";
+ }
+ }
+ return 0;
+}
+
sub nick {
my ($chk, $id, $event, $chan) = @_;
if ( lc $event->{nick} eq lc $chk->{content} ) {