From 300b8c1b26159578aef047b4968edc6bc3f924cb Mon Sep 17 00:00:00 2001 From: wowaname Date: Thu, 30 Mar 2017 01:16:28 +0000 Subject: [PATCH] parrot.pl: case insensitive buffer matching --- scripts/parrot.pl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/parrot.pl b/scripts/parrot.pl index 7b74562..e9dcabd 100644 --- a/scripts/parrot.pl +++ b/scripts/parrot.pl @@ -28,6 +28,8 @@ sub servchan lc weechat::buffer_get_string($buffer, 'localvar_channel')); } +sub ircbuf { weechat::buffer_search('irc', "(?i)".(join '.', @_)) } + sub getgroup { my ($server, $channel) = @_; @@ -121,7 +123,7 @@ sub irc_privmsg_notice for (getgroup($server, $channel)) { my ($to_serv, $to_chan, $flags, undef) = @$_; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); if ($message =~ /^\x01ACTION /i) { $message =~ s/^\x01ACTION |\x01$//g; sendto($to_serv, "/msg $to_chan * \x02$nick\x0f $message"); @@ -145,7 +147,7 @@ sub ircout_privmsg_notice for (getgroup($server, $channel)) { my ($to_serv, $to_chan, $flags, undef) = @$_; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); my $prefix = lc $cmd eq 'notice' ? 'notice' : 'msg'; if ($message =~ /^\x01ACTION /i) { $message =~ s/^\x01ACTION |\x01$//g; @@ -170,7 +172,7 @@ sub irc_join my ($to_serv, $to_chan, $flags, undef) = @$_; next unless $flags & $STAT; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); sendto($to_serv, "/notice $to_chan \x02$nick\x0f$host joined $server/$channel\x0f"); } @@ -189,7 +191,7 @@ sub irc_part my ($to_serv, $to_chan, $flags, undef) = @$_; next unless $flags & $STAT; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); sendto($to_serv, "/notice $to_chan \x02$nick\x0f left $server/$channel\x0f: $message"); } @@ -208,7 +210,7 @@ sub irc_kick my ($to_serv, $to_chan, $flags, undef) = @$_; next unless $flags & $STAT; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); sendto($to_serv, "/notice $to_chan \x02$nick\x0f kicked $target\x0f from $server/$channel\x0f: $message"); } @@ -229,7 +231,7 @@ sub irc_nick my ($to_serv, $to_chan, $flags, undef) = @$_; next unless $flags & $STAT; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); sendto($to_serv, "/notice $to_chan \x02$nick\x0f is now \x02$newnick\x0f"); } } @@ -250,7 +252,7 @@ sub irc_quit my ($to_serv, $to_chan, $flags, undef) = @$_; next unless $flags & $STAT; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); sendto($to_serv, "/notice $to_chan \x02$nick\x0f left $server: $message"); } } @@ -282,7 +284,7 @@ sub irc_topic my ($to_serv, $to_chan, $flags, undef) = @$_; next unless $flags & $MODE; next if $flags & $READ; - next unless weechat::buffer_search('irc', "$to_serv.$to_chan"); + next unless ircbuf("$to_serv.$to_chan"); sendto($to_serv, "/topic $to_chan $message"); }