A couple of plugins for WeeChat

When I moved to Linux, I looked for an IRC client. Originally, I wanted/looked for a GUI one, probably because coming from Windows I'm used to GUI applications.

Soon enough it looked like I wouldn't be able to find a client that would fit my needs, so I tried CLI clients, and eventually found WeeChat. It's a great client, does lots of things by itself, but also has scripting support to extend things even further.

Still, as I started to use it more and more, there were a few things I needed that I couldn't find scripts for. Probably, the easiest way to add them would have been to write such a script, either in perl, python, or any of the other languages supported by WeeChat.

Instead, I went with C plugins. The only reason, to be fair, is that I don't know anything about any of the (many) script languages supported by WeeChat, while I had been doing some C for a little while. So it was easier/faster for me to do so, is all.

weenick: Provides support for common NickServ operations

First of all, since I use registered nicks of a few networks, I wanted to be identified automatically. This could be done by a simple command triggered upon connection, but I also wanted that on reconnection the command to kill the ghost, the change of nick & do the identification all be done without me having to do anything. Laziness is strong with me. :)

weenick should handle all of that, and you can also define command(s) to be executed once identified.

It is configured through options under var.plugins.weenick.server_default.SETTING for "global" values, which will be used (as fallback) on all servers. You can also define options under var.plugins.server.SERVER.SETTING for settings to be used on server SERVER only.

The options are :

  • nick : your (registered) nickname. When defined, weenick will try to use that nick upon connection (in case WeeChat used another one). If the nick is already in use, killing the ghost will be triggered.

  • password : your password, to identify/kill ghost with services

  • command : command(s) to get processed upon identification

  • nickserv_nick : nickname to send messages to. Default: NickServ

  • nickserv_registered : string to identify notice that nick is registered Default: nickname is registered

  • nickserv_ghost_killed : string to identify notice that ghost was killed Default: ghost with your nick has been killed

  • nickserv_identified : string to identify notice that nick was identified Default: password accepted

  • nickserv_failed : string to identify notice that password is wrong Default: access denied

The nickserv_* options are there because not all servers uses the same strings for each case (starting with servers in another language than English, I guess).

(Of course, a match must happen in a NOTICE from NickServ (or whatever is specified as nickserv_nick) for it to be effective.)

Going over this, I realized the actual commands to kill ghost or identify are hard-coded, which probably isn't the best. Hopefully all services use the same, specifically: /msg <nickserv> GHOST <nick> <password> and /msg <nickserv> IDENTIFY <password>

(Registering your nick with services is all up to you, btw.)

weereact: Triggers commands in reaction to messages

Another thing I was after, was a way to have commands be triggered automatically in reaction to something that was said in a channel. Sort of a bot-like behavior, if you will.

weereact will allow to do just that: you can define "triggers" that will filter messages, and trigger the specified command(s) for each match.

Messages can be filtered by server, channel, user and content (through perl-compatible regular expression).

All configuration must be done in file weereact.conf in WeeChat's working directory (e.g. ~/.weechat). There's no interface, you need to manually edit the file in your favorite editor, and can use the /reload command to have weereact reload its config from the file.

Syntax in that file is pretty basic: Empty lines and lines starting with # are ignored; otherwise the format is simply: key=value

To start a new trigger definition, use the following on a new line: []

Options (keys) can be used to filter on which messages should the actions be triggered, as well as define said actions.

  • on : name of the server the message must be sent on

  • to : name of the channel (with #) or nick for PMs. For PMs send to yourself/you're receiving, use: to=-

  • by : name of the sender of the message. For messages you're sending, use: by=-

  • is : perl-compatible regex to filter the message.

  • do : command to be executed when a message matches. You can specify this option as many as times as you need. In addition to the back-references from the regex in is, you can also use the following variables:

  • $on : name of the server
  • $to : name of the #channel/nick the message is sent to
  • $by : name of the sender (only available if you're not sending the message)

New command: /tobuffer

One last thing this plugin does, is introduce a new command - /tobuffer - which can be used to send text (or commands) to a specific buffer.

It's very possible you don't need it for most things, since you can e.g. specify a server & channel with /msg for instance, but I needed to send text/command to plugin buffers (i.e. not IRC channel/privates).

Also, I'm not sure there's a way, from such a command, to do a /me does nothing Although you wouldn't need to use /tobuffer for that, if that needed to happen in the channel/private where the original message occured, as by default all text/commands sent by weereact are done to the buffer of the original message, IOW in the same channel/private as the original message.

Downloads and whatnot

weeplugins is released under GNU GPL v3+ The source code is available on this BitBucket repository, where bugs/suggestions can be added to the issue tracker.

Arch Linux users can also use the PKGBUILD in the AUR, which grabs the latest code from the GIT repo.

And of course, as always, new bug reports, suggestions or any other form of constructive criticism is very much welcome.

Top of Page