Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript

Web Topics
All Articles
Scripting Languages

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab

O'Reilly Book Excerpts: IRC Hacks

Hacking IRC

by Paul Mutton

Author's note: Many of my colleagues use IRC, and a few of us also have webcams so we can see what each other is up to. By combining an IRC client and a webcam, we can let people know what we're doing, even if it's not readily apparent by looking at the webcam.

Moderate Hack #30 Add Your IRC Nickname to Your Webcam

Webcams are the best way to let people know exactly what you're doing—after all, a picture is worth a thousand words, or so they say. Adding extra text to your webcam image can reveal a lot more, particularly if you are not there to be seen. This hack shows you how to display your current IRC nickname on your webcam image.

The Windows webcam software used in this hack is Dorgem. This unusual name doesn't actually mean anything; it is a combination of letters that could sound like a word and didn't return any results on search engines at the time of its creation. So the chances are that if you Google this, you'll be able to find it easily. If not, you can download it from http://dorgem.sourceforge.net.

One useful feature of Dorgem is that it allows you to overlay captions on your webcam image. These captions can be either bitmap images or plain text. If you go for the plain text option, you can choose to overlay a string that you type in, or tell it to read the contents of a file. The latter choice allows you to include whatever text is in the file, so you can easily create a script for your IRC client that updates the file with your current nickname.

Writing Your Nickname to a File

As this hack is to run on a Windows machine, it will use mIRC as the IRC client. To update the contents of the file every time you change your nickname, it's going to be necessary to trap that event. The easiest way of doing this is to override mIRC's /nick command so that it saves the new nickname in a file.

Open up the mIRC Scripts Editor (Tools → Scripts Editor...) and select the Aliases tab. Now create the alias for the /nick command shown in .

Modifying the behavior of mIRC's /nick command
Figure 1. Modifying the behavior of mIRC's /nick command

This overrides the /nick command and causes a sequence of three other commands to be executed instead. The first of these passes the $1 variable to the /nick command. $1 is the first argument that is supplied to your alias, so this has the effect of changing your nickname as usual.

The second line echoes a string to your active window so you can receive a confirmation of what your webcam message will say. $2- is a variable that refers to the second argument, including everything after it. This means you can add some more details after your nickname, and they will also be included in this message.

The third line writes the same message to a file. The -c means that the file will be cleared before it is written to. In this example, the message will be written to c:\temp\nick.txt.

The alias lets you add extra parameters to the /nick command in case you want to add more detail to your webcam message. For example, if Paul wants to change his nickname to Paul|desk-less, he can do so in the usual way by entering:

/nick Paul|desk-less

This would cause nick.txt to contain:

Current IRC nick: Paul|desk-less ...

If he wanted to include some more information about his nickname, he could simply add some more details after the /nick command:

/nick Paul|desk-less they came and stole my desk :(

This would cause nick.txt to contain:

Current IRC nick: Paul|desk-less ... they came and stole my desk :(

Now that you've configured your IRC client to keep this file up-to-date, you just have to set up Dorgem to display its contents on your webcam image.

IRC Hacks

Related Reading

IRC Hacks
100 Industrial-Strength Tips & Tools
By Paul Mutton

Pages: 1, 2

Next Pagearrow