Triggers

Simmo Saan edited this page Aug 11, 2018 · 121 revisions

IMPORTANT: all these triggers require WeeChat >= 1.1.

Note: You may need to replace \S with [^ ] on non-GNU platform (eg. FreeBSD).

Change messages displayed

Display URLs in color 32 (blue)

/trigger add url_color modifier "weechat_print" "${tg_tags} !~ irc_quit" ";[a-z]+://\S+;${color:32}${re:0}${color:reset};" ""

Modify messages starting with '>' to display green text

/trigger add greentext modifier "weechat_print" "${tg_message_nocolor} =~ ^>[^:._]" "/(.*)/${tg_prefix}\t${color:34}${tg_message}" ""

Darker join messages (with color 237)

/trigger add irc_join modifier 2000|weechat_print "${tg_tags} =~ ,irc_join," "/.*/${tg_prefix}\t${color:237}${tg_message_nocolor}"

Customize JOIN message

/trigger add irc_join modifier 2000|weechat_print "${tg_tags} =~ ,irc_join," "/.*[^(]\((.*)\).*/${color:237}${tg_tag_nick} with host ${re:1} joined ${channel}/tg_message_nocolor /.*/${tg_prefix}\t${tg_message_nocolor}"

Customize PART message

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

Customize QUIT message

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

Customize NICK message

/trigger add irc_nick modifier 2000|weechat_print "${tg_tags} =~ ,irc_nick," "/.*irc_nick1_([^,]*),irc_nick2_([^,]*).*/You are now known as ${re:2}, formerly known as ${re:1}/tg_tags /.*/${tg_prefix}\t${tg_tags}"

Customize ACTION message, using the nick color for the prefix

/trigger add nick_color_action modifier "weechat_print" "${tg_tags} =~ ,irc_action, && ${tg_tags} !~ ,self_msg," "/.*/${info:nick_color,${tg_tag_nick}}${tg_prefix_nocolor}\t${tg_message}" "" "" "none"

Colors for join/part/quit/nick/mode/disconnect

join/part/quit colors

/trigger add join modifier "weechat_print" "${tg_tags} =~ irc_join|irc_nick_back" ";\(\x1927([a-zA-Z0-9^~@:./_-]+)[^a-z]+\);${color:28}(${color:22}${re:1}${color:28}); ;([#&!]\S+);${color:0}${re:1};" ""
/trigger add part modifier "weechat_print" "${tg_tags} =~ irc_part" ";\(\x1927([a-zA-Z0-9^~@:./_-]+)[^a-z]+\);${color:124}(${color:88}${re:1}${color:124}); ;\(\x19...([^@]+)\x19..\);${color:124}(${color:88}${re:1}${color:124}); ;([#&]\S+);${color:238}${re:1}; ;([#&]\S+$);${color:0}${re:1};" ""
/trigger add quit modifier "weechat_print" "${tg_tags} =~ irc_quit" ";\(\x1927([a-zA-Z0-9^~@:./_-]+)[^a-z]+\);${color:88}(${color:52}${re:1}${color:88}); ;\(\x19...([^@]+)\x19..\);${color:88}(${color:52}${re:1}${color:88});" ""
/trigger add mode modifier "weechat_print" "${tg_tags} =~ irc_mode" ";Mode;${color:240}Mode; ; by ; ${color:240}by ; ;(\+\S+);${color:29}${re:1}; ;\[\x1c(-\S+);[${color:137}${re:1};" ""
/trigger add nick modifier "weechat_print" "${tg_tags} =~ irc_nick" ";is now known as;${color:242}is now known as;" ""
/trigger add disconnect modifier "weechat_print" "${tg_tags} !~ . && ${tg_buffer} !~ irc.server." "; irc: disconnected from server;\t$${color:240}irc: disconnected from server$;" ""

Append a label to messages from a certain user

/trigger add userlabel modifier "weechat_print" "" "/^[^@]+@(.+)$/${re:1}/tg_tag_host /^.+$/${re:0} ${color:darkgray}${plugins.var.trigger.userlabel.${tg_tag_host}}" ""

This trigger uses hostname of user from variable ${tg_tag_host} to determine what label should be appended. Since the variable contains both username and host, we strip it off using the first regex. The second regex is for appending the label that is stored in option plugins.var.trigger.userlabel.*.

To test, set label [idiot] for user with host unaffiliated/tomoe-mami/x-1769741:

/set plugins.var.trigger.userlabel.unaffiliated/tomoe-mami/x-1769741 [idiot]

Relaybot

<botnick> <foo> message --> <foo> message

weechat_print level change:

/trigger add relaybot modifier weechat_print "${tg_tag_host} == ~bot@botmask" "/.*<([^>]+)> (.*)/${re:1}\t${re:2}/"

IRC message level change:

/trigger add relaybot2 modifier "irc_in2_privmsg" "${nick} == botnick" "/^(:)(botnick)(!\S+@\S+ )(PRIVMSG #channel :)<(\S+)> (.*)/${re:1}${re:5}${re:3}${re:4}${re:6}/" ""

Relaybot 2

/trigger add relaybot modifier "weechat_print" "${buffer.full_name} != perl.highmon && ${tg_tag_nick} =~ ${plugins.var.trigger.relaybot.nick}" "/^([^\t]*)\t[[<]([^]>]+)(\]|>)\s?(.*)$/${color:red}→${info:nick_color,${re:2}}${re:2}\t${re:4}/" "" "" "none"
/trigger add relaybot_action modifier "weechat_print" "${tg_tags} =~ ,irc_action, && ${buffer.full_name} != perl.highmon && ${tg_tag_nick} =~ ${plugins.var.trigger.relaybot.nick}" "/^[^\t]*\t(\S*)\s[[<]([^]>]+)(\]|>)\s?(.*)$/${tg_prefix}\t${color:red}→${info:nick_color,${re:2}}${re:2}${color:reset} ${re:4}/" "" "" "none"

Create option plugins.var.trigger.relaybot.nick and into it write a regex by which nicknames are matched for relay bots, for example ^relaybot*$.

Colors messages based on gender

Shows messages in pink when a woman is talking and blue if he's a man. You need to enable the mouse. Then press the middle-click button on a nickname in the nicklist and press 'f' if she's a woman or 'm' for a man.

/key bindctxt cursor @item(buffer_nicklist):f /window ${_window_number};/trigger add female_${nick} modifier weechat_print "\${tg_tags} =~ ,irc_privmsg, && \${tg_tag_nick} == ${nick}" "/(.*)/\${tg_prefix}\t\${color:magenta}\${tg_message}/";/cursor stop
/key bindctxt cursor @item(buffer_nicklist):m /window ${_window_number};/trigger add male_${nick} modifier weechat_print "\${tg_tags} =~ ,irc_privmsg, && \${tg_tag_nick} == ${nick}" "/(.*)/\${tg_prefix}\t\${color:lightblue}\${tg_message}/";/cursor stop

Color your own messages

/trigger add color_my_lines modifier "weechat_print" "${tg_tags} =~ ,nick_YOURNICK," "/.*/${tg_prefix}\t${color:196}${tg_message_nocolor}" ""

Dim messages coming from a certain nick (alternative to ignoring)

Adds /dim and /undim commands

screenshot of dimmed user

/alias add dim trigger addreplace dim_$server_$1 modifier weechat_print "${tg_tag_nick} == $1 && \${server} == $server" "/(.*)/${color:darkgray}${tg_prefix_nocolor}\t${color:darkgray}${tg_message_nocolor}/"; print \---\t$1 is now dimmed on $server
/alias add undim trigger del dim_$server_$1; print \---\t$1 is no longer dimmed

Modifies dim trigger when the user changes nick

/trigger addreplace dim_change_nick signal *,irc_in_nick "" "" "/trigger rename dim_${server}_${nick} dim_${server}_${text}; /trigger set dim_${server}_${text} conditions \"\${tg_tag_nick} == ${text} && \${server} == ${server}\""

Hides core.weechat messages for dim_ triggers (so your core buffer doensn't get spammed with "trigger not found", "trigger renamed" and "trigger modified" messages)

/filter add block_dim_messages core.weechat no_trigger dim_

Remove colors from nick and message (in channel #weechat)

/trigger add no_color modifier "weechat_print" "${channel} =~ #weechat && ${tg_tags} =~ ,irc_privmsg," "/(.*)/${tg_prefix_nocolor}\t${tg_message_nocolor}" ""

Move znc messages to server buffer

/trigger add znctoserver modifier "irc_in_privmsg" "${host} == *status!znc@znc.in || ${host} == *controlpanel!znc@znc.in || ${host} == *identfile!znc@znc.in || ${host} == *q!znc@znc.in" "/.*//" "/print -buffer server.${server} znc: ${text}"

Max size for nicks when prefix_align is none

prefix_align_max only works when using prefix alignment but nick length limiting may be useful without as well. Modify the length after ${curscr: as desired.

/trigger addreplace nick_cut modifier weechat_print "" "/^([^\t]*)\t(.*)$/${cutscr:10,+,${re:1}}\t${re:2}/"

Bitlbee Twitter - replace t.co links with expanded URLs

Only replace full URLs:

/trigger addreplace tcoexpand modifier weechat_print "${channel} =~ #twitter_" "!https://t.co/[^ ]+ <([^>…]+)>!https://${re:1}!"

Remove truncated expanded URLs:

/trigger addreplace notcoexpand modifier weechat_print "${channel} =~ #twitter_" "!<[^…]+…>!!"

React to incoming messages

Execute a command when "FlashCode" joins Channel #weechat on freenode

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

Show a libnotify desktop notification via notify-send

More complicated than it needs to be because it HTML escapes "", """, "&", "<" and ">" because of libnotify oddities and uses tg_message as a temporary variable.

/trigger add osd print '' '${tg_highlight}' '/.*/${weechat.look.nick_prefix}${tg_prefix_nocolor}${weechat.look.nick_suffix} ${tg_message_nocolor}/ /&/&amp;/ /[\\]/&#92;/ /"/&quot;/ /</&lt;/ />/&gt;/' '/exec -norc -nosw notify-send -i weechat "${buffer.full_name}" "${tg_message}"'

Also notify on private messages:

/trigger add osd2 print '' '(${tg_highlight} || ${tg_tag_notify} == private) && ${buffer.notify} > 0' '/.*/${weechat.look.nick_prefix}${tg_prefix_nocolor}${weechat.look.nick_suffix} ${tg_message_nocolor}/ /&/&amp;/ /[\\]/&#92;/ /"/&quot;/ /</&lt;/ />/&gt;/' '/exec -norc -nosw notify-send -i weechat "${buffer.full_name}" "${tg_message}"'

Auto-respond with "pong" to "ping" queries

/trigger add pong print "" "${type} == private && ${tg_message} == ping" "" "pong"

Auto-respond with "nick: bar" to someone saying ".foo"

/trigger add foobar print "" "${tg_notify} && ${tg_tag_nick} && ${tg_message_nocolor} == .foo" "" "${tg_tag_nick}: bar"

Respond a given text embedded in "((my text))"

/trigger add respond print "" "${tg_message_nocolor} =~ \(\((.*)\)\)" "/.*\(\((.*)\)\).*/${re:1}/" "your text: ${tg_message}" "ok"

Run /whois when a query buffer is opened (v. 1.3+)

/trigger add whois_on_query signal irc_pv_opened
/trigger set whois_on_query command /command -buffer ${buffer[${tg_signal_data}].full_name} * wii ${buffer[${tg_signal_data}].local_variables.channel}

A few notes:

  1. In a signal trigger, ${buffer} always points to current buffer not the buffer where the signal occurred.
  2. Because of point 1, we have to use /command -buffer to prevent Weechat from executing the command in the wrong buffer.
  3. To get the buffer where the signal occurred and all its properties we have to use the hdata syntax: ${buffer[<pointer>].<property>}. In irc_pv_opened signal, the variable ${tg_signal_data} contains the newly created buffer pointer so we use that.
  4. irc_pv_opened signal doesn't have variable for the target/recipient nickname of a query buffer. There is ${nick} but it's for your own nickname. The only way to get the target nickname is by accessing buffer's local variable channel (not to be confused with IRC channel). That's why we use ${buffer[${tg_signal_data}].local_variables.channel} for /wii parameter.

Automatic mode

Create an Alias called aop that allows you to op (or any other mode +o, +v) a user based on their host on channel join (useful for networks without services) -- You have to use /aop on the buffer you want the auto op on, also this now works on networks other than freenode but you will need at least WeeChat 1.0-dev (git: v0.4.3-566-gfe872f2) [May 28th] as there was a bug originally.

/alias add aop /trigger addreplace opme$2 signal *,irc_in_join "${server}.${channel}.${host} =~ $server.$channel.$1" "" "/quote -server $server mode $channel +o ${nick}"

/aop *!*@example.org name

Temporary topic lock

Sometimes you want people to be able to change the topic in your channel but you'd like to enforce a delay before the topic can be set again, thus when topic changes set +t, wait, set -t -- Example for channel ##vp on server named "freenode" (look at /help wait to adjust the delay):

/trigger addreplace topiclock signal *,irc_in_topic "${server}.${channel} =~ freenode.##vp" "" "/quote -server freenode mode ##vp +t;/wait 2m /quote -server freenode mode ##vp -t"

The above can be made generic using /alias like in the first example. irc_in_* is a signal name, this can be very useful, as you can see irc_in_join and irc_in_topic were used, but there are many more, just look at the tags.

Automatically try rejoining when blocked by join throttle or channel limit

/trigger addreplace jointhrottle_retry signal *,irc_in2_480;*,irc_in2_471 "" "" "/print -buffer irc.server.${server} Attempting rejoin to ${channel} in 1 minute; /wait 60 /join -noswitch -server ${server} ${channel}"

Away log - print highlights to server buffer when you're away

/trigger add awaylog print "" "${tg_highlight} && ${away}" "" "/print -buffer server.${server} ${color:darkgray}${buffer.short_name} ${tg_prefix}${color:${weechat.color.chat_nick_suffix}}${weechat.look.nick_suffix} ${tg_message}"

Block incoming messages

Block all IRC CTCP messages except ACTION (/me)

/trigger add block_ctcp modifier "irc_in_privmsg" "${arguments} =~ ^[^ ]+ :${\x01}.*${\x01}$ && ${arguments} !~ ^[^ ]+ :${\x01}ACTION" "/.*//"

Block query from nick "FlashCode"

"channel" has to be your own nick

/trigger add block_query_FlashCode modifier "irc_in_privmsg" "${tg_modifier_data} == freenode && ${nick} == FlashCode && ${channel} == ${info:irc_nick,${server}}" "/.*//" ""

Block private messages from users without +x usermode (QuakeNet and UnderNet)

/trigger add quakenet_undernet_pm signal quakenet,irc_in_privmsg;undernet,irc_in_privmsg "${host} !~ (users.quakenet.org|users.undernet.org|znc@znc.in) && ${channel} == ${info:irc_nick,${server}}" "" "/msg -server ${server} ${nick} Please set the umode +x to chat with me.;/quote -server ${server} silence +${host}" "ok"

Modify outgoing messages

Replace outgoing IRC messages, like text_replace.py

/trigger add replacebox modifier irc_out1_PRIVMSG "" "/\[x\]/☑/ /\[ \]/☐"

Remove spaces at the end of message/command sent

/trigger add spaces_out modifier "input_text_for_buffer" "" "/ +$//"

Replace ' by in outgoing messages (except commands):

    /trigger add apostrophe modifier "input_text_for_buffer" "${tg_string} !~ ^/"  "/([a-zA-Z])'([a-zA-Z])/${re:1}’${re:2}/"

Same trigger and replace also in input display:

    /trigger add apostrophe modifier "input_text_for_buffer;input_text_display" "${tg_string} !~ ^/"  "/([a-zA-Z])'([a-zA-Z])/${re:1}’${re:2}/"

Display

Toggle time display on buffer, like toggle_time.py

/trigger add cmd_toggle_time command toggle_time
/trigger set cmd_toggle_time regex /.*/${weechat.look.buffer_time_format}\n/tg_argv0 /^[^\n]+\n$//tg_argv0 /^\n$/${tg_argv1}/tg_argv0
/trigger set cmd_toggle_time command /mute /set weechat.look.buffer_time_format "${tg_argv0}"

The \n in the regex part is needed because WeeChat's regex can not replace empty string (/^$/${tg_argv1}/tg_argv0 doesn't work).

After creating this trigger you can run /toggle_time followed by format of time. For example: /toggle_time %H:%M:%S

On Weechat >= 1.8, you can simplify the trigger by removing the regex part and just use the new ${if:} format:

/trigger set cmd_toggle_time regex ""
/trigger set cmd_toggle_time command /mute /set weechat.look.buffer_time_format "${if:${weechat.look.buffer_time_format}==?${tg_argv1}:}"

Enable hotlist changes for buffers displayed in inactive windows (requires perlexec.pl)

/set weechat.look.hotlist_add_conditions "${away} || ${buffer} != ${window.buffer}"
/trigger addreplace windowswitch signal window_switch "" "" "/perlexec weechat::buffer_set(weechat::window_get_pointer('${tg_signal_data}','buffer'), 'hotlist', -1);"

Reset read marker when switching away from a buffer displayed in an inactive window (requires perlexec.pl)

/trigger add bufferswitch signal "buffer_switch" "" "" "/perlexec weechat::buffer_set(weechat::hdata_get_list(weechat::hdata_get('buffer'),'gui_buffer_last_displayed'), 'unread', 0)\;"

Fix artefacts seen in some circumstances after a buffer switch

/trigger add force_redraw signal "window_switch;buffer_switch" "" "" "/wait 1ms /redraw"

Hide buffers after 100 seconds of inactivity, if they aren't on the hotlist (requires perlexec.pl)

/trigger addreplace detach timer 10000;0;0 "" "" "/allchan /eval /perlexec weechat::command('', '/command -buffer irc.\${server}.\${channel} core /buffer hide') if ((${date:%s} - \${buffer[\${info:irc_buffer,\${server},\${channel}}].lines.last_line.data.date}) > 100 && '\${window.buffer.full_name}' !~ 'irc.\${server}.\${channel}' && '\${buffer[\${info:irc_buffer,\${server},\${channel}}].hotlist}' eq '0x0')"

And unhide them on any new messages, or if you manually switch to a hidden buffer

/trigger addreplace reattach print "" "${buffer.hidden} == 1 && ${tg_tag_notify} == message" "" "/command -buffer irc.$server.$channel core /buffer unhide"
/trigger addreplace reattach_on_switch signal buffer_switch "${buffer[${tg_signal_data}].hidden} == 1" "" "/command -buffer ${buffer[${tg_signal_data}].full_name} core /buffer unhide"

print an empty line after each message

/trigger add space signal "*,irc_in_privmsg;*,irc_out_privmsg" "" "" "/print -buffer ${server}.${channel}" "ok" "none"

Input line

Different color for commands

/trigger add input_command_color modifier "500|input_text_display" "${tg_string} =~ ^/($|[^/])" "#/(.+)#${color:39}/${color:74}${re:1}#"

Preview colors of weechat.color.chat_nick_colors in input bar (demo)

/trigger add preview_nick_colors modifier 2000|input_text_display
/trigger set preview_nick_colors conditions ${tg_string} =~ ^/set\s+weechat\.color\.chat_nick_colors\s+
/trigger set preview_nick_colors regex /^\S+\s+\S+(.+)$/${re:1}/tg_string_nocolor /([^",]+)/${color:${re:1}}${re:1}${color:default}/tg_string_nocolor /^(\S+\s+\S+).*$/${re:1}${tg_string_nocolor}/tg_string

Tab-complete to the last nickname who sent a message to current channel

Similar to script zerotab.py, this will complete the last nickname who sent message to current channel if you press Tab while Weechat's input is empty. It needs two triggers. The first one is for watching incoming message and putting the nickname who sent that message into buffer's localvar last_nick.

/trigger add last_nick print irc.*;notify_message
/trigger set last_nick conditions ${tg_displayed} && ${type} == channel && ${tg_tag_nick} != ${nick}
/trigger set last_nick command /buffer set localvar_set_last_nick ${tg_tag_nick}

The second one is for inserting the value of localvar last_nick to input bar.

/trigger add complete_last_nick command_run "/input complete_next"
/trigger set complete_last_nick conditions ${type} == channel && ${buffer.input_buffer_length} == 0 && ${last_nick}
/trigger set complete_last_nick command /input insert ${last_nick}

Prevent sending commands as messages when preceded by space

/trigger add spacecmd modifier input_text_for_buffer "${tg_string} =~ ^\s+/" /.*// "/print "${tg_string_nocolor}" prevented"

Keys

Run on key combo

Prints TEST to core buffer when meta-t is pressed:

/trigger add key_test signal key_combo_default "${tg_signal_data} == ${\01}[t" "" "/print -core TEST"

To use modifiers in key_combo_* signal triggers the following has to be taken into account:

  • meta- should be checked as ${\01}[
  • ctrl- should be checked as ${\01}

Relay

Clear away on relay connect

/trigger add relay_awayclear signal relay_client_connected "" "" "/away -all"

Set away on relay disconnect

/trigger add relay_setaway signal relay_client_disconnected "" "" "/away -all I am away"

Set away when last relay client disconnects

/trigger add relay_setaway signal relay_client_disconnected "${info:relay_client_count,connected} == 0" "" "/away -all I am away"

Reload SSL certificate on SIGHUP

Useful for calling from an ACME client post-renew hook (killall -s HUP weechat or similar).

/trigger addreplace hup_relay_ssl signal "3000|signal_sighup" "" "" "/relay sslcertkey" "ok_eat"

Timers

Auto-away

We can use trigger to automatically set away status after certain amount of inactivity. A timer trigger will be used for checking ${info:inactivity} (variable that contains the amount of seconds with no key/mouse activity) and setting the away status. For removing the away status, we'll use a signal key_pressed trigger. There is one problem with signal key_pressed. Weechat treats special keys like arrow up/F1/Home/etc as multiple "keys" (for example, arrow up is ^[, [, and A) and will call the trigger multiple times. This means we can not simply use /away inside this trigger to remove the away status because it will send IRC command AWAY to server multiple times. We're going to need a custom away command.

/trigger add cmd_custom_away command custom_away
/trigger set cmd_custom_away conditions (${tg_argv_eol1} && ${plugins.var.trigger.away_flag} != on) || (${tg_argv_eol1} == && ${plugins.var.trigger.away_flag} == on)
/trigger set cmd_custom_away regex /.+/${tg_argv1}\n/tg_argv0 /^.+\n$/on/tg_argv0 /^\n$/off/tg_argv0
/trigger set cmd_custom_away command /mute /away -all ${tg_argv_eol1};/mute /set plugins.var.trigger.away_flag ${tg_argv0}

That ${tg_argv_eol1} == in the condition isn't a typo. That's how to check if a variable is not set inside trigger.

If you're using Weechat >= 1.2 you can replace plugins.var.trigger.away_flag with environment variable (so you won't clutter plugins.conf). For example:

/trigger set cmd_custom_away conditions (${tg_argv_eol1} && ${env:weechat_away} != on) || (${tg_argv_eol1} == && ${env:weechat_away} == on)
/trigger set cmd_custom_away command /mute /away -all ${tg_argv_eol1};/mute /set env weechat_away ${tg_argv0}

You can test the new command by running:

/custom_away foo
/custom_away bar
/custom_away
/custom_away

If the trigger is correctly set, only the first and the third command will have any effect.

Now we create the timer trigger and set its interval to 5 minutes (300000 ms):

/trigger addoff autoaway_idle_timer timer 300000;0;0
/trigger set autoaway_idle_timer conditions ${info:inactivity} >= 300
/trigger set autoaway_idle_timer command /custom_away Auto-away after 5 min. of no activity;/mute /trigger enable autoaway_idle_key;/wait 1s /mute /trigger disable autoaway_idle_timer

The /wait 1s is needed because Weechat prevent a trigger from disabling itself while it's still running.

Next is the key pressed trigger:

/trigger addoff autoaway_idle_key signal key_pressed
/trigger set autoaway_idle_key command /custom_away;/mute /trigger enable autoaway_idle_timer;/wait 1s /mute /trigger disable autoaway_idle_key

Finally to test it just run /trigger enable autoaway_idle_timer and idle for 5 minutes.

Upgrade scripts at midnight

/trigger add upgrade_scripts signal day_changed "" "" "/script update;/wait 10s /script upgrade" "ok"

Cycle through buffer list after ten second of inactivity

/trigger add cycle timer 5000 "${info:inactivity} > 10" "" "/buffer +1"

Other

Kickban with mouse

Auto kick ban a user with his host when you press 'B' on a nick in cursor mode (you need the perlexec.pl script).

There is a little problem: we /who the user in case his host do not figure in the infolist. But the /who will be useful only if the last channel the user joined is the channel we want to kickban him (https://github.com/weechat/weechat/issues/470) Otherwise you could remove /who ${nick} and put /who ${channel}. If you do that you may want to change /wait 2s to /wait 5s

/key bindctxt cursor @item(buffer_nicklist):b /window ${_window_number};/who ${channel};/wait 2s /perlexec my $infolist = weechat::infolist_get("irc_nick", "", q(${server},${channel},${nick}))\;weechat::infolist_next($infolist)\;my $host = (split("@", weechat::infolist_string($infolist, "host")))[1]\;if (!defined($host)) { weechat::command("", q(/print -core I dont have the host of ${nick} please try again))\; } else { weechat::command("", q(/trigger addreplace auto_kb_${server}_${channel}_${date:%Y_%m_%d_%H_%M_%S} signal ${server},irc_in_join "\${channel} =~ ${channel} && \${host} =~ ) . $host . q(" "" "/command -buffer irc.${server}.${channel} irc /kickban ${channel} ${nick}!*@) . $host . q( bye bye" "ok"))\;weechat::command("", q(/kickban ${channel} ${nick} bye bye))\; } weechat::infolist_free($infolist);/cursor stop

Post-join commands

Use this to run a command after joining a channel, through autojoin or manually:

/trigger add [name] signal "irc_channel_opened" "${buffer[${tg_signal_data}].full_name} =~ [channel_name]" "" "[command]"

Replace [name], [channel_name], and [command] with what you're after, of course.

As as example, you may want to login to a channel bot, but said channel bot won't let you login to it unless you're in the same channel that it's in. Not a problem. Replace [command] with something like /msg -server [server_name] [bot_nick] [msg_command], like this:

/msg -server freenode foobot login myname mypass

Put it all together and the trigger should look close to this:

/trigger add postjoincmd signal "irc_channel_opened" "${buffer[${tg_signal_data}].full_name} =~ #funtimes" "" "/msg -server freenode chanbot login myname mypass"

Huge thanks to nils_2 and sim642 in #weechat for the information needed to put this together.

Show closed buffers

Prints full buffer names into core buffer when they are closed. Useful for seeing what buffer you closed if you used /close accidentally.

/trigger add close_report signal "buffer_closing" "" "" "/print -core Buffer closed: ${buffer[${tg_signal_data}].full_name}"

Run /upgrade -quit on signal SIGTERM

To run the command /upgrade -quit when SIGTERM is received by WeeChat:

/trigger add sigterm signal "2000|signal_sigterm" "" "" "/upgrade -quit" "ok_eat" "none"

Run /upgrade -quit when terminal is closed (SIGHUP)

/trigger add hupgrade signal "signal_sighup" "" "" "/upgrade -quit" "ok" "none"

Jump to buffer with command: /<nn>

/trigger add numberjump modifier "2000|input_text_for_buffer" "${tg_string} =~ ^/[0-9]+$" "=\/([0-9]+)=/buffer *${re:1}=" "" "" "none"

Add/remove a channel to autojoin option (requires autojoinem.py)

/trigger add autojoin signal "*,irc_in_join" "" "" "/autojoinem add ${server} ${channel};/mute save" "ok" "none"
/trigger add autopart signal "*,irc_in_part" "" "" "/autojoinem del ${server} ${channel};/mute save" "ok" "none"

Fix /notify on freenode

Freenode incorrectly announced MONITOR support in 005 message but actually doesn't support it so /notify doesn't work. This removes the incorrect support announcement, allowing fallback to polling.

/trigger add freenode_monitor modifier "irc_in_005" "${tg_modifier_data} == freenode" "/MONITOR ?//" ""

Stuck?

Remember /trigger monitor trigger_name and /debug tags (run again to disable).

Documentation: https://weechat.org/files/doc/devel/weechat_user.en.html#trigger_plugin

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.