From 8ff9ba40fcbfc00260466509c4cbb95d43f8b682 Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Thu, 14 Jan 2016 14:50:40 -0700 Subject: Register command-processing handlers inside of the command module, rather than having the event handler module call the command handler module --- lib/ASM/Commander.pm | 4 ++++ lib/ASM/Event.pm | 2 -- meta.pl | 4 ++-- 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; -- cgit v1.2.3