From e857c1e04913b4a21871956b3d27e07a730da919 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 13 Sep 2018 18:42:44 +1200 Subject: Allow modules to handle for ignored nicks --- idalius.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/idalius.pl b/idalius.pl index f773a4f..0bf2e5f 100755 --- a/idalius.pl +++ b/idalius.pl @@ -201,14 +201,11 @@ sub handle_common { my $channel = $where->[0]; my $output; - # Return early if should ignore - return if should_ignore($nick); - $what =~ s/^\s+|\s+$//g; my $stripped_what = strip_color(strip_formatting($what)); my $no_prefix_what = $stripped_what; - if ($config{prefix_nick} && $no_prefix_what =~ s/^\Q$current_nick\E[:,]\s+//g || + if (!should_ignore($nick) && $config{prefix_nick} && $no_prefix_what =~ s/^\Q$current_nick\E[:,]\s+//g || $no_prefix_what =~ s/^$config{prefix}//) { $output = run_command($no_prefix_what, $who, $where); $irc->yield(privmsg => $where => $output) if $output; @@ -217,8 +214,18 @@ sub handle_common { # handler names are defined as being prefixed with on_ $message_type = "on_$message_type"; + my $ignore_suffix = "_yes_really_even_from_ignored_nicks"; for my $module (@{$config{plugins}}) { - if (module_is_enabled($module) && $module->can($message_type)) { + if (module_is_enabled($module)) { + if (!should_ignore($nick) and $module->can($message_type)) { + # Leave message type unchanged + } elsif ($module->can($message_type.$ignore_suffix)) { + # Handler for non-ignored and ignored exists + $message_type = $message_type.$ignore_suffix; + } else { + # No handler + next; + } $output = $module->$message_type(\&log_info, $irc->nick_name, $who, $where, $what, $stripped_what, $irc); $irc->yield(privmsg => $where => $output) if $output; strike_add($nick, $channel) if $output; -- cgit v1.1