weechat – NHL Goal – trigger

Today, I will show you how to automatically take what GoalBot write in the ##reddit-hockey and then display it in your channel with the power of weechat trigger. You need at least weechat 1.1 (you can with weechat 1.0 but you will need to replace each occurence of ${re:#} to $#. For example: ${re:1} become $1)

I will show you how to catch Montreal and Ottawa goals. Let’s begin.

First, we want to react to a signal, in our case the irc_in_privmsg but only when the message contains “Goal” or “Le But”. When any team, except Montreal, score a goal, GoalBot write something like this:

 <GoalBot> Goal: N.J RYDER,M. 35' Snap (3:21 3rd) [3-1]

but when the habs score a goal, the bot write “Le But” instead of “Goal”:

<GoalBot> Le But: MTL BOURNIVAL,M. 6' Snap (2:47 3rd) [3-0]

We also need to catch message that contains “Scoring Change”. So let’s go:

/trigger add habsgoal signal freenode,irc_in_privmsg "${nick} == GoalBot && ${tg_signal_data} =~ (Le But|Scoring Change).*\sMTL\s" "/(.*):(.*):(.*):(.*)/${re:2}:${re:3}:${re:4}/arguments" "/msg -server undernet #nullepart ${arguments}" "ok"
/trigger add sensgoal signal freenode,irc_in_privmsg "${nick} == GoalBot && ${tg_signal_data} =~ (Goal|Scoring Change).*\sOTT\s" "/(.*):(.*):(.*):(.*)/${re:2}:${re:3}:${re:4}/arguments" "/msg -server undernet #nullepart ${arguments}" "ok"

In my case, weechat writes the goal in the #nullepart channel on undernet.

If you want to catch the goals of a specific player, for example Michael Bournival:

/trigger add bournivalgoal signal freenode,irc_in_privmsg "${nick} == GoalBot && ${tg_signal_data} =~ (Le But|Scoring Change).*\sMTL\s.*Bournival" "/(.*):(.*):(.*):(.*)/${re:2}:${re:3}:${re:4}/arguments" "/msg -server undernet #nullepart ${arguments}" "ok"

or catch any goal:

/trigger add nhlgoal signal freenode,irc_in_privmsg "${nick} == GoalBot && ${tg_signal_data} =~ (Le But|Goal|Scoring Change)" "/(.*):(.*):(.*):(.*)/${re:2}:${re:3}:${re:4}/arguments" "/msg -server undernet #nullepart ${arguments}" "ok"

Enjoy the playoff!

weechat, bitlbee and twitter

You can now add twitter filter channel with bitlbee! In this post, I will show you how to create that kind of channel. Then, I will use weechat /filter command (nothing to do with bitlbee twitter filter) to block RT messages.

In my case, I would like to see messages with hashtag #quebec, #montreal and #longueuil. To do that, I will type:

/msg -server bitlbee &bitlbee chat add twitter track:#quebec;track:#montreal;track:#longueuil #quebec

Then, I should expect to receive the following message from root:

Chatroom successfully added.

So I track hashtag #quebec, #montreal and #longueuil in the IRC channel #quebec. So let’s join #quebec

/join -server bitlbee #quebec

Now to block RT message, we use the weechat filter command like this:

/filter add rt irc.bitlbee.#quebec * ^\[.*\]\sRT\s

That’s it!

Note that you can change twitter hashtag at any time with the following command:

/msg -server bitlbee &bitlbee channel #quebec set room track:#quebec;track:#montreal;track:#longueuil;track:#habs;track:#gohabsgo #quebec

You could also use the follow option instead of track to create a sublist of your following:

/msg -server bitlbee &bitlbee chat add twitter follow:lifehacker;follow:howtogeek;follow:makeuseof #tech-howto

You could also block messages from some user with weechat:

/filter add pascalpoitras irc.bitlbee.#quebec nick_pascalpoitras *

This will block all messages from pascalpoitras


WeeChat – Ignore

In WeeChat, there are three commands that can be used to hide or ignore messages from specific people:

  • the ignore command
  • the filter command
  • the trigger command

and I found two scripts that hide just the messages, while still showing the chat activity by specified users:

Let’s start!

The ignore command

The ignore command is used to ignore everything from a nick or host on a channel, server or everywhere. The following command for instance would ignore all messages from r3m on channel #defocus on the freenode server:

/ignore add r3m freenode #defocus

Note: the ignored messages are deleted and are not logged. If you only want to hide the messages and still log them, then you should use the /filter command instead.

Note 2: this ignore filter would be very easy to get around though, as the person would only have to change their nickname

You can use the * wildcard to ignore, for example, all nicknames beginning with Guest:

/ignore add Guest*

or use a regex:

/ignore add re:^Guest.*

To list the ignore, type:

/ignore list

then to delete the first entry, type:

/ignore del 1

and to delete all the entry type:

/ignore del -all

The filter command

The filter command is used for two things:

  • hide everything from a user
  • hide everything that matches your specified regular expression

To hide every join/part/quit message everywhere:

/filter add partquit * irc_join,irc_part,irc_quit *

To hide everything from r3m on #defocus:

/filter add r3mdefocus irc.freenode.#defocus nick_r3m *

To hide every line from r3m which contains only ‘lol’ on every channel and server:

/filter add r3mlol * nick_r3m ^lol$

Note: the ^ indicates the beginning of the sentence, and $ indicates the end of the line. In other words, where lol is the only thing in the sentence. Just ^lol would match every sentence that starts with ‘lol’, while lol$ would match every sentence that ends with ‘lol’, whereas just lol would match every sentence that includes ‘lol’.

To list the filters, type:

/filter list

then to delete the first entry, type:

/filter del 1

:and to remove every filter, type:

/filter del -all

The trigger command

The trigger command is very complex and can be used for hundred different things. If you want to ignore everything from nils_2 and FlashCode, use this command (thanks nils_2)

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

it will replace text from nils_2 and FlashCode with “text cloaked” message.

I will add other examples soon.

The curiousignore.pl script

if you dislike ignoring people because it becomes difficult to follow the discussion, you could use the curiousignore.pl script. This way, you will see the nickname but not the message.

/script install curiousignore.pl
/set plugins.var.perl.curiousignore.blacklist "freenode.#defocus.r3m,freenode.#weechat.Rick18"

The shutup.py script

This script is similar to curiousignore.pl. By default, it replaces the text of the ‘muted’ person with a random line from the Jabberwocky poem. At the time of writing, the shutup.py script is not in the official repository yet. You can however already download it from FiXato’s git repository

mkdir -p ~/.weechat/python && wget https://raw2.github.com/FiXato/weechat_scripts/master/shutup.py -O ~/.weechat/python/shutup.py

and then load it from within WeeChat with:

/script load shutup.py

or you could wait till it has been accepted into WeeChat’s official scripts repo and install it via the script plugin:

/script install shutup.py

Now let’s start:

/set plugins.var.python.shutup.muted_masks @\S+\.aol\.com$:#comcast,#AT&T

This will replace any text from customers of aol in the channels #comcast and #AT&T. To replace any line from any tor users :

/set plugins.var.python.shutup.muted_masks @gateway\/tor-sasl\/

As you can see you can omit the channel to enable replacement everywhere. To replace any text from r3m and FiXato :

/set plugins.var.python.shutup.muted_masks r3m! FiXato!

So you must separate the targets by a space. To replace something with your own custom text :

/set plugins.var.python.shutup.replacement_text :(

will replace the text with a sad smile

I heard that FlashCode is working hard on a new command called ‘trigger’ so this post may become outdated soon. I’ll try to update the post then.


I’d like to thank FiXato for his help with proofreading my blog posts. If you need some proofreading done, you could try contacting Filip H.F. “FiXato” Slagter.