From e258d5a64d837681fbb870943c8a191d7ffd626c Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 14 Jul 2017 19:21:07 +1200 Subject: Strip formatting in idalius.pl once instead of each module --- idalius.pl | 4 +++- plugin/tittilate.pm | 4 +--- plugin/url_title.pm | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/idalius.pl b/idalius.pl index 8f9f81b..ef157ec 100755 --- a/idalius.pl +++ b/idalius.pl @@ -8,6 +8,7 @@ use POE::Kernel; use POE::Component::IRC; use POE::Component::IRC::Plugin::NickServID; use config_file; +use IRC::Utils qw(strip_color strip_formatting); use Module::Pluggable search_path => "plugin", instantiate => 'configure'; my $config_file = "bot.conf"; @@ -116,7 +117,8 @@ sub irc_public { return if (grep {$_ eq $nick} @{$config{ignore}}); for my $module (@plugin_list) { - my $output = $module->message($irc->nick_name, $who, $where, $what); + my $stripped_what = strip_color(strip_formatting($what)); + my $output = $module->message($irc->nick_name, $who, $where, $what, $stripped_what); $irc->yield(privmsg => $where => $output) if $output; } diff --git a/plugin/tittilate.pm b/plugin/tittilate.pm index b7994c3..d9d8a49 100644 --- a/plugin/tittilate.pm +++ b/plugin/tittilate.pm @@ -4,7 +4,6 @@ package plugin::tittilate; use strict; use warnings; -use IRC::Utils qw(strip_color strip_formatting); my %config; @@ -16,8 +15,7 @@ sub configure { } sub message { - my ($self, $me, $who, $where, $what) = @_; - $what = strip_color(strip_formatting($what)); + my ($self, $me, $who, $where, $raw_what, $what) = @_; my $gathered = ""; my @expressions = (keys %{$config{triggers}}); my $expression = join '|', @expressions; diff --git a/plugin/url_title.pm b/plugin/url_title.pm index 654b2ae..f36ad6d 100644 --- a/plugin/url_title.pm +++ b/plugin/url_title.pm @@ -6,7 +6,6 @@ use strict; use warnings; use HTTP::Tiny; use HTML::HeadParser; -use IRC::Utils qw(strip_color strip_formatting); my %config; @@ -19,11 +18,9 @@ sub configure { sub message { - my ($self, $me, $who, $where, $what) = @_; + my ($self, $me, $who, $where, $raw_what, $what) = @_; my $url; - $what = strip_color(strip_formatting($what)); - if ($what =~ /(https?:\/\/[^ ]+)/i) { $url = $1; } -- cgit v1.1