Saw thl’s blog on an irssi notification script. Was looking for something like that in xchat also. The result is this.
Copy the file in your ~/.xchat2/ folder, and it will be loaded next time you start xchat.