A more recent version of scripts may be available at scripts.irssi.org.
Version: 1.0
Download
View source
signature
Trigger is a script that execute a command or replace text, triggered by an event in irssi.
You could see it as a replacement for lots of small scripts, while it can still be used without knowing perl.
This is the documentation for the latest released version. For older versions, either upgrade or see /help trigger
TRIGGER LIST
TRIGGER SAVE
TRIGGER RELOAD
TRIGGER MOVE <number> <number>
TRIGGER DELETE <number>
TRIGGER CHANGE <number> ...
TRIGGER ADD ...
When to match:
On which types of event to trigger:
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
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.
Additionally, there is:
rawin: raw text incoming from the server
send_command: commands you give to irssi
send_text: lines you type that aren't commands
beep: when irssi beeps
notify_join: someone in you notify list comes online
notify_part: someone in your notify list goes offline
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
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.
-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
-tags: The servertag must be in the given list of tags
-channels: The event must be in one of the given list of channels.
Examples: -channels '#chan1 #chan2' or -channels 'IRCNet/#channel'
-channels 'EFNet/' means every channel on EFNet and is the same as -tags 'EFNet'
-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)
-other_masks
-other_hasmode
-other_hasflag: Same as above but for the victim for kicks or mode_nick.
What to do when it matches:
-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
The following variables are also expanded:
$T: Server tag
$C: Channel name
$N: Nickname of the person who triggered this command
$A: His address (foo@bar.com),
$I: His ident (foo)
$H: His hostname (bar.com)
$M: The complete message
${other}: The victim for kicks or mode_nick
${mode_type}: The type ('+' or '-') for a mode_channel or mode_nick
${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:
-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:
Knockout people who do a !list:
/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'
Ignore all non-ops on #channel:
/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'
Examples with -replace:
Replace every occurence of shit with sh*t, case insensitive:
/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 ''
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'
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'
Convert a Windows-1252 Euro to an ISO-8859-15 Euro (same effect as euro.pl):
/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 ' '
0.6