parrot.pl: case insensitive buffer matching

This commit is contained in:
wowaname 2017-03-30 01:16:28 +00:00
parent 603f9df8c3
commit 300b8c1b26
1 changed files with 10 additions and 8 deletions

View File

@ -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");
}