summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2016-01-14 14:50:40 -0700
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2016-01-14 14:50:40 -0700
commit8ff9ba40fcbfc00260466509c4cbb95d43f8b682 (patch)
treeb2d3a4d0e71b27931625194054365561a0613c80
parentda7d90773b8acf3dde1731f81237bb451ab73e33 (diff)
Register command-processing handlers inside of the command module, rather than having the event handler module call the command handler module
-rw-r--r--lib/ASM/Commander.pm4
-rw-r--r--lib/ASM/Event.pm2
-rwxr-xr-xmeta.pl4
3 files changed, 6 insertions, 4 deletions
diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm
index 054c57c..f53781f 100644
--- a/lib/ASM/Commander.pm
+++ b/lib/ASM/Commander.pm
@@ -142,9 +142,13 @@ my $cmdtbl = {
sub new {
my $module = shift;
+ my ($conn) = @_;
my $self = {};
$self->{cmdtbl} = $cmdtbl;
+ $self->{CONN} = $conn;
bless($self);
+ $conn->add_handler('msg', sub { command($self, @_); }, "after");
+ $conn->add_handler('public', sub { command($self, @_); }, "after");
return $self;
}
diff --git a/lib/ASM/Event.pm b/lib/ASM/Event.pm
index 90ba542..3d7beb6 100644
--- a/lib/ASM/Event.pm
+++ b/lib/ASM/Event.pm
@@ -311,7 +311,6 @@ sub on_part
sub on_msg
{
my ($conn, $event) = @_;
- $::commander->command($conn, $event);
ASM::Util->dprint($event->{from} . " - " . $event->{args}->[0], 'msg');
if ((ASM::Util->notRestricted($event->{nick}, "nomsgs")) && ($event->{args}->[0] !~ /^;;/)) {
# disabled by DL 130513 due to spammer abuse
@@ -337,7 +336,6 @@ sub on_public
else { $conn->schedule( 1, sub { checkHTTP($conn); } ); }
}
$::inspector->inspect( $conn, $event );
- $::commander->command( $conn, $event );
$::sc{$chan}{users}{lc $event->{nick}}{msgtime} = time;
}
diff --git a/meta.pl b/meta.pl
index a5132e2..4591417 100755
--- a/meta.pl
+++ b/meta.pl
@@ -6,7 +6,7 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";;
-use Net::IRC 0.90;
+use Net::IRC 0.91;
use Data::Dumper;
use IO::All;
use Getopt::Long;
@@ -133,8 +133,8 @@ sub init {
}
$::inspector = ASM::Inspect->new();
$::services = ASM::Services->new();
- $::commander = ASM::Commander->new();
$::event = ASM::Event->new($conn, $::inspector);
+ $::commander = ASM::Commander->new($conn);
$::classes = ASM::Classes->new();
$::fifo = ASM::Fifo->new($irc, $conn);
my @nickbl = io('nick_blacklist.txt')->getlines;