From: Doug Freed Date: Wed, 28 Dec 2022 09:41:39 +0000 (+0000) Subject: trigger: match irc op_public as publics X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=32e6f51f5d42beae8876fe7670ef96417e9cff20;p=irssi-scripts.irssi.org.git trigger: match irc op_public as publics These are often called statusmsg or wallchops, and are often also used by channel modes that cause messages that would otherwise be blocked to be sent to chanops. Also adds a prefix filter to allow differentiating these from regular publics. --- diff --git a/scripts/trigger.pl b/scripts/trigger.pl index 133b856..eae7d81 100644 --- a/scripts/trigger.pl +++ b/scripts/trigger.pl @@ -23,7 +23,7 @@ use Text::ParseWords; use IO::File; use vars qw($VERSION %IRSSI); -$VERSION = '1.2.7'; +$VERSION = '1.3.0'; %IRSSI = ( authors => 'Wouter Coekaerts', contact => 'wouter@coekaerts.be', @@ -82,6 +82,10 @@ All filters except for -pattern and -regexp can also be inversed by prefixing wi -other_masks -other_hasmode -other_hasflag: %|Same as above but for the victim for kicks or mode_nick. + -prefix: %|For publics, match what prefix the message was sent to (eg statusmsg, +z). Space separated list, use '' to match only messages sent to no prefix (ie, plain publics only) + Examples: %|-prefix '@' matches messages sent to @#channel + %|-prefix '@ +' matches messages sent to @#channel or +#channel, but not @+#channel + %|-prefix '' matches only messages sent to #channel, not @#channel or any other %U%_What to do when it matches%_%U -command: Execute the given Irssi-command @@ -187,6 +191,17 @@ my @signals = ( 'signal' => 'message public', 'sub' => sub {check_signal_message(\@_,1,$_[0],$_[4],$_[2],$_[3],'publics');}, }, +# "message irc op_public", SERVER_REC, char *msg, char *nick, char *address, char *target +{ + 'types' => ['publics'], + 'signal' => 'message irc op_public', + 'sub' => sub { + my ($prefix, $channel); + $channel = $_[4]; + $prefix = substr($channel, 0, 1, ''); + check_signal_message(\@_,1,$_[0],$channel,$_[2],$_[3],'publics',{'prefix'=>$prefix}); + }, +}, # "message private", SERVER_REC, char *msg, char *nick, char *address { 'types' => ['privmsgs'], @@ -527,7 +542,26 @@ my %filters = ( my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; return (($param) eq $extra->{'mode_arg'}); } -} +}, +'prefix' => { + 'types' => ['publics'], + 'sub' => sub { + my ($param, $signal,$parammessage,$server,$channelname,$nickname,$address,$condition,$extra) = @_; + + return 0 unless defined($extra->{'prefix'}) || $param eq ''; + return 1 unless defined($extra->{'prefix'}); + + my $matches = 0; + foreach my $prefix (split(/ /, $param)) { + if ($extra->{'prefix'} eq $prefix) { + $matches = 1; + last; + } + } + + return $matches; + } +}, ); sub get_address {