Shallow Thoughts : tags : irc

Akkana's Musings on Open Source Computing, Science, and Nature.

Wed, 26 Sep 2012

Writing xchat scripts in Python (to play sound alerts)

I use xchat as my IRC client. Mostly I like it, but its sound alerts aren't quite as configurable as I'd like. I have a few channels, like my Bitlbee Twitter feed, where I want a much more subtle alert, or no alert at all. And I want an easy way of turning sounds on and off, in case I get busy with something and need to minimize distractions.

Years ago I grabbed a perl xchat plug-in called "Smet's NickSound" that did something close to what I wanted. I've hacked a few things into it. But every time I try to customize it any further, I'm hit with the pain of write-only Perl. I've written Perl scripts, honest. But I always have a really hard time reading anyone else's Perl code and figuring out what it's doing. When I dove in again recently to try to figure out why I was getting so many alerts when first starting up xchat, I finally decided: learning how to write a Python xchat script couldn't be any harder than reverse engineering a Perl one.

First, of course, I looked for an existing nick sound Python script ... and totally struck out. In fact, mostly I struck out on finding any xchat Python scripts at all. I know there are Python bindings for xchat, because there's documentation for them. But sample plug-ins? Nope. For some reason, nobody's writing xchat plug-ins in Python.

I eventually found two minimal examples: this very simple example and the more elaborate utf8decoder. I was able to put them together and cobble up a working nick sound plug-in. It's easy once you have an example to work from to help you figure out the event hook arguments.

So here's my own little example, which may help the next person trying to learn xchat Python scripting: chatsounds.py on github.

Tags: , , ,
[ 21:13 Sep 26, 2012    More programming | permalink to this entry | comments ]

Mon, 14 Feb 2011

Starting a line with a slash in xchat

As most veteran IRC users know, IRC commands generally start with a slash at the beginning of a line. For instance, you say
/join #channel
to join a new channel, or
/me waves to everyone
to send "*akk waves to everyone" to the channel.

Great, but what if I want to start a line with a slash?

On some IRC clients, you can type two slashes, e.g.

/ /me tries
but on xchat that doesn't work -- it just complains "unknown command".

On xchat, what you need is /say:

/say /me succeeds!

Silly little tip, but I know I'll forget it if I don't record it ... and I bet I'm not the only xchat user wondering how to do this.

Update: it turns out that sometimes in xchat you can use a double slash with no spaces:
//me tries
which is the obvious thing to try, but it hasn't always worked reliably for me. Try it ... but you can fall back on /say if // doesn't work.

Tags: , ,
[ 20:55 Feb 14, 2011    More linux | permalink to this entry | comments ]

Syndicated on:
LinuxChix Live
Ubuntu Women
Women in Free Software
Graphics Planet
DevChix
Ubuntu California
Planet Openbox
Devchix
Planet LCA2009

Friends' Blogs:
Ups & Downs
DailyBBG
Long Live the Village Green
Dan Heller
Morris "Mojo" Jones
Jane Houston Jones

Other Blogs:
DevChix
Scott Adams
Dave Barry
BoingBoing (Cory Doctorow)
Young Female Scientist

Powered by PyBlosxom.