summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2007-07-04 02:00:24 +0000
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2007-07-04 02:00:24 +0000
commit2e39d5b2b95c2e705fd962c9752070f816c1dfec (patch)
tree64d6fde2a4cd488d7add12ca4897daee216777ae
parent6fe4d3ecbdc3196c7c62b9b7e00d5063bd0dbee9 (diff)
critical bug fix + code optimizations
-rw-r--r--config-default/channels.xml1
-rw-r--r--config-default/commands.xml12
-rwxr-xr-xmeta.pl5
-rw-r--r--modules/classes.pl14
-rw-r--r--modules/command.pl1
-rw-r--r--modules/event.pl2
-rw-r--r--modules/inspect.pl3
-rw-r--r--modules/log.pl27
8 files changed, 47 insertions, 18 deletions
diff --git a/config-default/channels.xml b/config-default/channels.xml
index 035fcd4..de9800b 100644
--- a/config-default/channels.xml
+++ b/config-default/channels.xml
@@ -193,6 +193,7 @@
<event id="wikifags2" action="none" class="re" nocase="nocase" reason="saying 'sure are a lot of wikifag'..." risk="low" time="0" type="public">sure are a ?lot of wikifag</event>
<event id="dcc-part" action="ban" class="re" reason="using the DC.C SE.ND exploit in a part message" risk="high" time="0" type="part">DCC SEND </event>
<event id="levenflood" action="none" class="levenflood" reason="levenshtein flood match" risk="debug" time="0" type="public" override="flood-5to3">contentisuseless</event>
+ <event id="blacklist" action="none" class="strbl" reason="sending pm matching string blacklist" risk="low" time="0" type="public">blah</event>
<hilights>
<debug>AfterDeath</debug>
</hilights>
diff --git a/config-default/commands.xml b/config-default/commands.xml
index 5e5f9e8..8353b0f 100644
--- a/config-default/commands.xml
+++ b/config-default/commands.xml
@@ -179,8 +179,8 @@
<command cmd="^;exempt (.*)" flag="o">
<![CDATA[
$::eline{lc $1} = 1;
- "lc $1\n" >> io 'exempt.txt';
- $conn->privmsg($event->{to}->[0], "lc $1 exempted");
+ lc $1 . "\n" >> io 'exempt.txt';
+ $conn->privmsg($event->{to}->[0], lc $1 . " exempted");
]]>
</command>
<command cmd="^\!ops *(.*)">
@@ -199,4 +199,12 @@
}
]]>
</command>
+ <command cmd="^;blacklist (.*)" flag="o">
+ <![CDATA[
+ my $str = lc $1;
+ push(@::string_blacklist, $str);
+ "$str\n" >> io 'string_blacklist.txt';
+ $conn->privmsg($event->{to}->[0], "$str blacklisted");
+ ]]>
+ </command>
</commands>
diff --git a/meta.pl b/meta.pl
index 4b71024..61f97ff 100755
--- a/meta.pl
+++ b/meta.pl
@@ -16,6 +16,7 @@ use Getopt::Long;
%::eline=();
$::pass = '';
+@::string_blacklist=();
BEGIN {
my @modules = qw/Xml Util Inspect Event Services Log Command Classes Actions Mysql OperQueue/;
@@ -32,6 +33,7 @@ sub init {
'config|c:s' => \$::cset
);
ASM::XML->readXML();
+ mkdir($::settings->{log}->{dir});
$::log = ASM::Log->new($::settings->{log});
$::pass = $::settings->{pass} if $::pass eq '';
$host = ${$::settings->{server}}[rand @{$::settings->{server}}];
@@ -57,6 +59,9 @@ sub init {
foreach my $item (@eline) {
$::eline{lc $item} = 1;
}
+ my @strbl = io('string_blacklist.txt')->getlines;
+ chomp @strbl;
+ @::string_blacklist = @strbl;
$irc->start();
}
diff --git a/modules/classes.pl b/modules/classes.pl
index 93c5e12..b540a9a 100644
--- a/modules/classes.pl
+++ b/modules/classes.pl
@@ -11,6 +11,7 @@ sub new
my $module = shift;
my $self = {};
my $tbl = {
+ "strbl" => \&strbl,
"dnsbl" => \&dnsbl,
"floodqueue" => \&floodqueue,
"nickspam" => \&nickspam,
@@ -147,6 +148,19 @@ sub re {
return 0;
}
+sub strbl {
+ my ($chk, $id, $event, $chan) = @_;
+ my $match = lc $event->{args}->[0];
+ foreach my $line (@::string_blacklist) {
+ my $xline = lc $line;
+ my $idx = index $match, $xline;
+ if ( $idx != -1 ) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
sub nick {
my ($chk, $id, $event, $chan) = @_;
if ( lc $event->{nick} eq lc $chk->{content} ) {
diff --git a/modules/command.pl b/modules/command.pl
index b0523c4..04f1d90 100644
--- a/modules/command.pl
+++ b/modules/command.pl
@@ -1,6 +1,7 @@
package ASM::Commander;
use warnings;
use strict;
+use IO::All;
sub new
{
diff --git a/modules/event.pl b/modules/event.pl
index ede0efd..971a542 100644
--- a/modules/event.pl
+++ b/modules/event.pl
@@ -4,6 +4,7 @@ use strict;
use Data::Dumper;
use Text::LevenshteinXS qw(distance);
+use IO::All;
#require 'modules/inspect.pl';
sub cs {
@@ -77,6 +78,7 @@ sub on_join {
my $chan = lc $event->{to}->[0];
if ( lc $conn->{_nick} eq lc $nick) {
$::sc{$chan} = {};
+ mkdir($::settings->{log}->{dir} . $chan);
$conn->sl("who $chan");
$conn->privmsg('ChanServ', "op $chan" ) if (defined cs($chan)->{op}) && (cs($chan)->{op} eq 'yes');
}
diff --git a/modules/inspect.pl b/modules/inspect.pl
index a5fd732..bed8a46 100644
--- a/modules/inspect.pl
+++ b/modules/inspect.pl
@@ -3,6 +3,7 @@ use warnings;
use strict;
use Data::Dumper;
+use List::Util qw(first);
%::ignored = ();
sub new
@@ -23,7 +24,7 @@ sub inspect {
my @override = [];
our $unmode='';
my $nick = lc $event->{nick};
- return if (defined($::eline{$nick}) || defined($::eline{lc $event->{user}}) || defined(lc $event->{host}));
+ return if (defined($::eline{$nick}) || defined($::eline{lc $event->{user}}) || defined($::eline{lc $event->{host}}));
$iaddr = gethostbyname($event->{host});
$rev = join('.', reverse(unpack('C4', $iaddr))).'.' if (defined $iaddr);
%monx = defined($::channels->{channel}->{master}->{event}) ? %{$::channels->{channel}->{master}->{event}} : ();
diff --git a/modules/log.pl b/modules/log.pl
index 759a3ea..e8a178a 100644
--- a/modules/log.pl
+++ b/modules/log.pl
@@ -1,12 +1,10 @@
+package ASM::Log;
+
use warnings;
use strict;
-package ASM::Log;
-
-#use String::Interpolate qw(interpolate);
-use IO::All;
+#use IO::All;
use POSIX qw(strftime);
-use Data::Dumper;
sub new
{
@@ -14,7 +12,6 @@ sub new
my $config = shift;
my $self = {};
$self->{CONFIG} = $config;
- $self->{MD} = {};
bless($self);
return $self;
}
@@ -30,11 +27,8 @@ sub logg
foreach my $chan ( @chans )
{
$chan = lc $chan;
- unless (defined($self->{MD}->{$chan}) && ($self->{MD}->{$chan} == 1)) {
- io($cfg->{dir} . $chan)->mkpath;
- $self->{MD}->{$chan} = 1;
- }
- $_='';
+ my $path = ">>$cfg->{dir}${chan}/${chan}" . strftime($cfg->{filefmt}, @time);
+ $_ = '';
$_ = "<$event->{nick}> $event->{args}->[0]" if $event->{type} eq 'public';
$_ = "*** $event->{nick} has joined $chan" if $event->{type} eq 'join';
$_ = "*** $event->{nick} has left $chan" if $event->{type} eq 'part';
@@ -45,10 +39,13 @@ sub logg
$_ = "-$event->{nick}- $event->{args}->[0]" if $event->{type} eq 'notice';
$_ = "*** $event->{nick} sets mode: " . join(" ",@{$event->{args}}) if $event->{type} eq 'mode';
$_ = "*** $event->{nick} changes topic to \"$event->{args}->[0]\"" if $event->{type} eq 'topic';
- print Dumper($event) if ($_ eq '');
- $_ = strftime($cfg->{timefmt}, @time) . $_ . "\n" unless $_ eq '';
- $_ >> io($cfg->{dir} . $chan . '/' . $chan . strftime($cfg->{filefmt}, @time)) unless ($_ eq '');
+ $_ = strftime($cfg->{timefmt}, @time) . $_ . "\n";
+ my $line = $_;
+ open(FH, $path) or die "Can't open $path: $!";
+ print FH $line;
+ close(FH);
+# $_ >> io($path);
}
}
-return 1;
+1;