From ae8b7a06e6b199923c5ff0c194891a924bf35015 Mon Sep 17 00:00:00 2001 From: Wouter Coekaerts Date: Sat, 7 Nov 2015 14:03:17 -0300 Subject: trigger.pl: Update to '1.0+' --- scripts/trigger.pl | 131 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 54 deletions(-) (limited to 'scripts/trigger.pl') diff --git a/scripts/trigger.pl b/scripts/trigger.pl index 02f8951..6b88cbd 100644 --- a/scripts/trigger.pl +++ b/scripts/trigger.pl @@ -1,7 +1,7 @@ # trigger.pl - execute a command or replace text, triggered by an event in irssi # Do /TRIGGER HELP or look at http://wouter.coekaerts.be/irssi/ for help -# Copyright (C) 2002-2006 Wouter Coekaerts +# Copyright (C) 2002-2010 Wouter Coekaerts # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ use Text::ParseWords; use IO::File; use vars qw($VERSION %IRSSI); -$VERSION = '1.0'; +$VERSION = '1.0+'; %IRSSI = ( authors => 'Wouter Coekaerts', contact => 'wouter@coekaerts.be', @@ -31,7 +31,7 @@ $VERSION = '1.0'; description => 'execute a command or replace text, triggered by an event in irssi', license => 'GPLv2 or later', url => 'http://wouter.coekaerts.be/irssi/', - changed => '$LastChangedDate: 2006-01-23 13:10:19 +0100 (Mon, 23 Jan 2006) $', + changed => '$LastChangedDate: 2009-02-07 21:35:47 +0100 (Sat, 07 Feb 2009) $', ); sub cmd_help { @@ -45,11 +45,11 @@ TRIGGER DELETE TRIGGER CHANGE ... TRIGGER ADD ... -When to match: -On which types of event to trigger: +%U%_When to match%_%U +%UOn which types of event to trigger%U These are simply specified by -name_of_the_type The normal IRC event types are: - publics, %|privmsgs, pubactions, privactions, pubnotices, privnotices, joins, parts, quits, kicks, topics, invites, nick_changes, dcc_msgs, dcc_actions, dcc_ctcps + publics, %|privmsgs, (pub|priv)actions, (pub|priv)notices, (pub|priv)ctcps, (pub|priv)ctcpreplies, joins, parts, quits, kicks, topics, invites, nick_changes, dcc_msgs, dcc_actions, dcc_ctcps mode_channel: %|a mode on the (whole) channel (like +t, +i, +b) mode_nick: %|a mode on someone in the channel (like +o, +v) -all is an alias for all of those. @@ -63,9 +63,11 @@ On which types of event to trigger: notify_away: %|someone in your notify list goes away notify_unaway: %|someone in your notify list goes unaway notify_unidle: %|someone in your notify list stops idling + (pub|priv)flood: %|flood in a channel or in private detected. See /set flood. Be careful, these flood signals can trigger many times for one flood (unless you have autoignore enabled) -Filters (conditions) the event has to satisfy. They all take one parameter. -If you can give a list, seperate elements by space and use quotes around the list. +%UFilters (conditions) the event has to satisfy%U +They all take one parameter. If you can give a list, seperate elements by space and use quotes around the list. +All filters except for -pattern and -regexp can also be inversed by prefixing with -not_. -pattern: %|The message must match the given pattern. ? and * can be used as wildcards -regexp: %|The message must match the given regexp. (see man perlre) %|if -nocase is given as an option, the regexp or pattern is matched case insensitive @@ -76,15 +78,15 @@ If you can give a list, seperate elements by space and use quotes around the lis -masks: %|The person who triggers it must match one of the given list of masks -hasmode: %|The person who triggers it must have the give mode Examples: %|'-o' means not opped, '+ov' means opped OR voiced, '-o&-v' means not opped AND not voiced - -hasflag: %|Only trigger if if friends.pl (friends_shasta.pl) or people.pl is loaded and the person who triggers it has the given flag in the script (same syntax as -hasmode) + -hasflag: %|Only trigger if friends.pl (friends_shasta.pl) or people.pl is loaded and the person who triggers it has the given flag in the script (same syntax as -hasmode) -other_masks -other_hasmode -other_hasflag: %|Same as above but for the victim for kicks or mode_nick. -What to do when it matches: +%U%_What to do when it matches%_%U -command: Execute the given Irssi-command %|You are able to use $1, $2 and so on generated by your regexp pattern. - %|For multiple commands ; (or $;) can be used as seperator + %|For multiple commands ; can be used as seperator %|The following variables are also expanded: $T: %|Server tag $C: %|Channel name @@ -98,42 +100,41 @@ What to do when it matches: ${mode_char}: %|The mode char ('o' for ops, 'b' for ban,...) ${mode_arg} : %|The argument to the mode (if there is one) %|$\X, with X being one of the above expands (e.g. $\M), escapes all non-alphanumeric characters, so it can be used with /eval or /exec. Don't use /eval or /exec without this, it's not safe. - -replace: %|replaces the matching part with the given replacement in the event (requires a -regexp or -pattern) -once: %|remove the trigger if it is triggered, so it only executes once and then is forgotten. -stop: %|stops the signal. It won't get displayed by Irssi. Like /IGNORE -debug: %|print some debugging info -Other options: +%U%_Other options%_%U -disabled: %|Same as removing it, but keeps it in case you might need it later -name: %|Give the trigger a name. You can refer to the trigger with this name in add/del/change commands -Examples: +%U%_Examples%_%U Knockout people who do a !list: - /TRIGGER ADD %|-publics -channels "#channel1 #channel2" -nocase -regexp ^!list -command "KN $N This is not a warez channel!" + %#/TRIGGER ADD %|-publics -channels "#channel1 #channel2" -nocase -regexp ^!list -command "KN $N This is not a warez channel!" React to !echo commands from people who are +o in your friends-script: - /TRIGGER ADD %|-publics -regexp '^!echo (.*)' -hasflag '+o' -command 'say echo: $1' + %#/TRIGGER ADD %|-publics -regexp '^!echo (.*)' -hasflag '+o' -command 'say echo: $1' Ignore all non-ops on #channel: - /TRIGGER ADD %|-publics -actions -channels "#channel" -hasmode '-o' -stop + %#/TRIGGER ADD %|-publics -actions -channels "#channel" -hasmode '-o' -stop Send a mail to yourself every time a topic is changed: - /TRIGGER ADD %|-topics -command 'exec echo $\N changed topic of $\C to: $\M | mail you@somewhere.com -s topic' + %#/TRIGGER ADD %|-topics -command 'exec echo $\N changed topic of $\C to: $\M | mail you@somewhere.com -s topic' -Examples with -replace: +%U%_Examples with -replace%_%U %|Replace every occurence of shit with sh*t, case insensitive: - /TRIGGER ADD %|-all -nocase -regexp shit -replace sh*t + %#/TRIGGER ADD %|-all -nocase -regexp shit -replace sh*t %|Strip all colorcodes from *!lamer@*: - /TRIGGER ADD %|-all -masks *!lamer@* -regexp '\x03\d?\d?(,\d\d?)?|\x02|\x1f|\x16|\x06' -replace '' + %#/TRIGGER ADD %|-all -masks *!lamer@* -regexp '\x03\d?\d?(,\d\d?)?|\x02|\x1f|\x16|\x06' -replace '' %|Never let *!bot1@foo.bar or *!bot2@foo.bar hilight you %|(this works by cutting your nick in 2 different parts, 'myn' and 'ick' here) %|you don't need to understand the -replace argument, just trust that it works if the 2 parts separately don't hilight: - /TRIGGER ADD %|-all masks '*!bot1@foo.bar *!bot2@foo.bar' -regexp '(myn)(ick)' -nocase -replace '$1\x02\x02$2' + %#/TRIGGER ADD %|-all masks '*!bot1@foo.bar *!bot2@foo.bar' -regexp '(myn)(ick)' -nocase -replace '$1\x02\x02$2' %|Avoid being hilighted by !top10 in eggdrops with stats.mod (but show your nick in bold): - /TRIGGER ADD %|-publics -regexp '(Top.0\(.*\): 1.*)(my)(nick)' -replace '$1\x02$2\x02\x02$3\x02' + %#/TRIGGER ADD %|-publics -regexp '(Top.0\(.*\): 1.*)(my)(nick)' -replace '$1\x02$2\x02\x02$3\x02' %|Convert a Windows-1252 Euro to an ISO-8859-15 Euro (same effect as euro.pl): - /TRIGGER ADD %|-regexp '\x80' -replace '\xA4' + %#/TRIGGER ADD %|-regexp '\x80' -replace '\xA4' %|Show tabs as spaces, not the inverted I (same effect as tab_stop.pl): - /TRIGGER ADD %|-all -regexp '\t' -replace ' ' + %#/TRIGGER ADD %|-all -regexp '\t' -replace ' ' SCRIPTHELP_EOF } # / @@ -164,16 +165,16 @@ my @allchanmsg_types = qw(publics pubactions pubnotices pubctcps pubctcpreplies # trigger types with a message my @allmsg_types = (@allchanmsg_types, qw(privmsgs privactions privnotices privctcps privctcpreplies dcc_msgs dcc_actions dcc_ctcps)); # trigger types with a channel -my @allchan_types = (@allchanmsg_types, qw(mode_channel mode_nick joins invites)); +my @allchan_types = (@allchanmsg_types, qw(mode_channel mode_nick joins invites pubflood)); # trigger types in -all my @all_types = (@allmsg_types, qw(mode_channel mode_nick joins invites nick_changes)); # trigger types with a server -my @all_server_types = (@all_types, qw(rawin notify_join notify_part notify_away notify_unaway notify_unidle)); +my @all_server_types = (@all_types, qw(rawin notify_join notify_part notify_away notify_unaway notify_unidle pubflood privflood)); # all trigger types my @trigger_types = (@all_server_types, qw(send_command send_text beep)); #trigger types that are not in -all #my @notall_types = grep {my $a=$_; return (!grep {$_ eq $a} @all_types);} @trigger_types; -my @notall_types = qw(rawin notify_join notify_part notify_away notify_unaway notify_unidle send_command send_text beep); +my @notall_types = qw(rawin notify_join notify_part notify_away notify_unaway notify_unidle send_command send_text beep pubflood privflood); my @signals = ( # "message public", SERVER_REC, char *msg, char *nick, char *address, char *target @@ -376,9 +377,22 @@ my @signals = ( 'sub' => sub { my ($server, $args, $nick, $addr, $target) = @_; if ($target eq $server->{'nick'}) { - check_signal_message(\@_, 1, $server, undef, $nick, $addr, 'privctcps'); + check_signal_message(\@_, 1, $server, undef, $nick, $addr, 'privctcpreplies'); } else { - check_signal_message(\@_, 1, $server, $target, $nick, $addr, 'pubctcps'); + check_signal_message(\@_, 1, $server, $target, $nick, $addr, 'pubctcpreplies'); + } + } +}, +# "flood", SERVER_REC, char *nick, char *host, int level, char *target +{ + 'types' => ['pubflood', 'privflood'], + 'signal' => 'flood', + 'sub' => sub { + my ($server, $nick, $host, $level, $target) = @_; + if ($target eq $server->{'nick'}) { + check_signal_message(\@_, -1, $server, undef, $nick, $host, 'privflood'); + } else { + check_signal_message(\@_, -1, $server, $target, $nick, $host, 'pubflood'); } } } @@ -539,8 +553,10 @@ sub hasmode { my @trigger_switches = (@trigger_types, qw(all nocase stop once debug disabled)); # parameters (with an argument) my @trigger_params = qw(pattern regexp command replace name); +# all options that can be used to set filters, including negative matches (not_) +my @trigger_filter_options = map(($_,'not_'.$_), keys(%filters)); # list of all options (including switches) for /TRIGGER ADD -my @trigger_add_options = (@trigger_switches, @trigger_params, keys(%filters)); +my @trigger_add_options = (@trigger_switches, @trigger_params, @trigger_filter_options); # same for /TRIGGER CHANGE, this includes the -no