Spam Filtering for Jabber?

I am frequently pained when Isomeone asks me a technical question on Jabber. I’d want to redirect them to the IRC channel #iitm-linux but I feel “obliged” to respond, and I hate to hide. So, I wanted some filtering, just like I have procmail for mail filtering, for Jabber chats as well – that way, I’ll be blissfully ignorant of unwanted messages.

So I hacked the MCabber source to introduce a programmable filter that any messages are passed through, before they flash my bulb. The modified files in the src directory of the mcabber tarball on the MCabber site are available here temporarily.

Just create an executable ~/.mcabber/filter and chmod it to atleast u+rx to get the filter working.

The filter can accept four command line args – The JID of the sender, The resource of the sender, The Message, and The Type of Message (as defined by MCabber) and must output the processed message to stdout. If the filter outputs nothing, then no message is displayed.

I’ve done something extremely dumb: I could’ve piped the message into stdin, instead of putting it as a command line argument. Most of my time went into trying to escape the quotes in the message, encountering lot of dumb bugs – I could’ve saved on that. Late realisation. 😦

Anyway, will fix that in future. There are many more interesting things to left to do – like passing the current status into the filter, so that you can vary the action of the filter depending on whether you’re away, busy or available, and hacking MCabber to get DBus support and writing a MCabber Remote to create programmable autoresponders!

Advertisements