WeeChat DevCenter

Trigger plugin

A new plugin called "trigger" has been added.

This plugin can hook many things:

  • signal
  • hsignal
  • modifier
  • print
  • command
  • command_run
  • timer
  • config
  • focus

When the callback is called, trigger can:

  • check some conditions (to execute the trigger or not), which are evaluated (see /help eval)
  • replace some text using regular expression(s)
  • execute command(s)
  • have a custom return code.

Example of things you can do with trigger:

  • notification, for example beep on highlight/private message (it can replace script beep.pl or other scripts)
  • hide passwords in commands/messages (it will replace rmodifier plugin)
  • change content of messages displayed
  • change things displayed (nicklist, ...) when terminal becomes small
  • regularly save config files (with a timer)
  • ...

Help is available with /help trigger.

Some examples of triggers can be found on GitHub WeeChat wiki.

Comments

1. On Friday, February 21 2014, 17:07 by nils_2

suppress messages from nick "nils_2" and "FlashCode" and print text "text cloaked" with color 238:

/trigger add shut_up modifier 2000|weechat_print "${tg_tags} =~ ,irc_privmsg,&&,nick_nils_2,|,nick_FlashCode," "/.*/${tg_prefix}\t${color:238}text cloaked"

2. On Friday, February 21 2014, 17:11 by nils_2

execute an external command when nick "nils_2" joins channel "#weechat" on server "freenode".
Remember, you'll need the "shell.py" script to run an external command:

/trigger add jnotify signal *,irc_in_join "${server}.${channel}.${nick} =~ freenode.#weechat.nils_2" "" "/shell beep -f 400"

3. On Friday, February 21 2014, 17:30 by nils_2

customise IRC Messages:
===================

trigger will only darken the original join message:
/trigger add irc_join modifier 2000|weechat_print "${tg_tags} =~ ,irc_join," "/.*/${tg_prefix}\t${color:237}${tg_message_nocolor}"

trigger will customise join message. The message will look like this:
The person nils_2 with host (~nils_2@hostname) joined channel #weechat
/trigger add irc_join modifier 2000|weechat_print "${tg_tags} =~ ,irc_join," "/.*[^(](\(.*\)).*/${color:237}the person ${tg_tag_nick} with host $1 joined channel ${channel}/tg_message_nocolor /.*/${tg_prefix}\t${tg_message_nocolor}"

trigger will customise part message:
/trigger add irc_part modifier 2000|weechat_print "${tg_tags} =~ ,irc_part," "/.*[^(](\(.*\)).*\ (\(.*\))/${color:237}${tg_tag_nick} with host $1 part ${channel} with message $2/tg_message_nocolor /.*/${tg_prefix}\t${tg_message_nocolor}"

trigger will customise quit message:
/trigger add irc_quit modifier 2000|weechat_print "${tg_tags} =~ ,irc_quit," "/.*[^(](\(.*\)).*\ (\(.*\))/${color:237}${tg_tag_nick} with host $1 quit ${channel} with message $2/tg_message_nocolor /.*/${tg_prefix}\t${tg_message_nocolor}"

trigger will customise nick message. The message will look like this:
You are now known as nils_2, formerly knows as FlashCode
/trigger add irc_nick modifier 2000|weechat_print "${tg_tags} =~ ,irc_nick," "/.*irc_nick1_([^,]*),irc_nick2_([^,]*).*/You are now known as $2, formerly known as $1/tg_tags /.*/${tg_prefix}\t${tg_tags}"

4. On Saturday, March 1 2014, 14:00 by xt

Respond to message
-----------------------------

When someone write irssi sucks, respond that they are wrong

/trigger add riposte signal *,irc_in2_PRIVMSG "${server}.${channel} =~ freenode.#weechat && ${message_without_tags} =~ irssi sucks" "" "/msg -server ${server} ${channel} You are wrong!"