WeeChat – Auto KickBan

If you press the middle mouse button on a nick in the nicklist and then press the ‘b’ key, you will ban the user with the default mask (option irc.network.ban_mask_default). By default, it is:

*!$ident@host

I replace mine with:

 *!*@$host

This is fine but I would prefer to add them in a auto kickban list. There is no way to obtain the host when we press the ‘b’ key (only the nick). A solution is to use the perlexec.pl script. So we will modify the bind for the ‘b’ key. First, install the script:

/script install perlexec.pl

then type this:

/key bindctxt cursor @item(buffer_nicklist):b /window ${_window_number};/who ${nick};/wait 2s /perlexec my $infolist=weechat::infolist_get("irc_nick", "", '${server},${channel},${nick}')\;weechat::infolist_next($infolist)\;my $hostname = (split("@", weechat::infolist_string($infolist, "host")))[1]\;weechat::command("", '/trigger addreplace auto_kb_${server}_${channel}_${nick}_${date:%Y_%m_%d_%H_%M_%S} signal ${server},irc_in_join "\\${channel} =~ ${channel} && \\${host} =~ ' . $hostname . '" "" "/quote -server ${server} MODE ${channel} +b *!*@' . $hostname . '\;/command -buffer irc.${server}.${channel} irc /kick ${channel} ${nick} bye bye" "ok"')\;weechat::command("", '/kickban ${channel} ${nick} bye bye')\;weechat::infolist_free($infolist);/cursor stop

This create a new trigger that exec two commands when a user in the auto kickban list joins the channel:

/quote -server ${server} MODE ${channel} +b *!*@$hostname
/command -buffer irc.${server}.${channel} irc /kick ${channel} ${nick} bye bye

you may ask “why not use /kickban instead”. I tried with /kickban but this ban the nick only. I don’t know why. So instead I send a raw mode message. You may also ask why you use /command instead of /kick directly. If you use /kick directly you will get this message:

irc: command "kick" must be executed on irc buffer (server or channel)

Then after created the trigger, we kickban the user. /kickban works here.

/kickban ${channel} ${nick} bye bye"

If you prefer to add the hostname to the autoban list of the X bot (undernet) and ChanServ (freenode, oftc, …) you could type:

/key bindctxt cursor @item(buffer_nicklist):b /window ${_window_number};/who ${nick};/wait 2s /perlexec my $infolist=weechat::infolist_get("irc_nick", "", '${server},${channel},${nick}')\;weechat::infolist_next($infolist)\;my $hostname = (split("@", weechat::infolist_string($infolist, "host")))[1]\;weechat::command("", ('${server}' eq "undernet") ? '/msg -server ${server} x@channels.undernet.org ban ${channel} *!*@' . $hostname . ' 100d 300 bye bye' : '/msg -server ${server} chanserv@services. akick ${channel} add *!*@' . $hostname . ' !P bye bye | Default ban');/cursor stop

This way we don’t need any trigger!

I use the second bind. I prefer to add the people to the services bot ban list. This is more powerful.

If you prefer to keep the default bind for ‘b’, you could create a ‘B’ bind. This way, you could use ‘b’ to ban someone only temporary or use ‘B’ to add him to the auto kickban list.

Now I’m ready to control my channel more accurately. As fast as a graphical IRC client!

WeeChat – Trigger – Women in pink and men in blue

Today I decided to mix two weechat command to produce something useless! Well, not so useless. I would like to “tell” weechat who is a woman and who is man. So whenever a known woman writes something I would like to see the text in pink. If it’s a man, blue.

Of course we are not going to manually create a trigger for every users. Instead, we will middle-click a nickname in the nicklist and then press the ‘f’ key if she’s a woman or ‘m’ key if he’s a man. We need to use the /key command for this. So here is the result:

/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

this is for women. Now let’s create one for men:

/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

That’s it!

WeeChat – multiple aspell dictionary

On the freenode IRC network, I am both on english and french channels. French channels generally end with “-fr”, I can put french as the default dictionary and then use the -exclude argument to set the english dictionnary on channel not ending with “-fr”:

/set aspell.check.default_dict fr
/allchan -exclude=*fr aspell setdict en
On the undernet IRC network, I am only on french channels. So move to the undernet buffer and set all chan to french:
/buffer undernet
/allchan -current aspell setdict fr
Do not forget to set the number of suggestions:
/set aspell.check.suggestions 3
/set aspell.color.suggestions *green
and to enable aspell:
/aspell enable