XChat away plugin

My computer pretty much stays connected to an IRC server. If I’m not in  one of my favorite forums channels, I’m into something else.

If you do frequent IRC, you will want to register your nick with the nickserv so no one else steals your name. This is a great feature, but if your like me and registered two nick’s, you’ll have to identify with both every time. You might be wondering, “Two nicks? Why?” Well, I use one nick for my presence “techb” and “techb_away” when I’m not active. This may spark a new question, why not use the /away and /back commands? Well, I’m lazy, and for people who use a cli client like Irssi or rolled their own just cause, setting your nick to away might not show them your away. So, I use two nick’s to distinguish when I’m there and not.

Also, I’ve been wanting to get into writing plug-ins for XChat. I will be posting in the coming days/weeks on bringing the solidstate to XChat. So stay tuned for what might happen when XChat meets ATMega328.

Anyway here’s le code:

import xchat

__module_name__ = "PyAway"
__module_version__ = "1.0"
__module_description__ = "Changes nick to away, and identifys with the nickserv"

awaynick = "techb_away"
backnick = "techb"
passwrd = "lolzyeahright"

def toggleAway(words, words_eol, userdata):
    if xchat.get_info("nick") == backnick:
        xchat.command("nick %s" % awaynick)
        xchat.command("msg nickserv identify %s" % passwrd)

    elif xchat.get_info("nick") == awaynick:
        xchat.command("nick %s" % backnick)
        xchat.command("msg nickserv identify %s" % passwrd)

xchat.hook_command("away_", toggleAway)
print "Loaded away.py /away_ \nUse to toggle."

module_name, module_version, and module_description is required to develop plug-ins.

We then define a function to handle the XChat callbacks. In this function we check to see what our current nick is. If it’s techb we change it to techb_away, and vice versa.

The last thing we do, is hook in our new command, by passing what we’re looking for and the function to handle the command callback.

You may have noticed where all the /’s are? We don’t need them because the xchat module we imported handles all them for us. To use this new plug-in, place it in the XChat directory and use “/py load modulename.py”. Once this script is in the root directory of XChat, it will automaticly load every time you open XChat.

To use this plug-in once it is loaded, simple type in “/away_” to toggle between nick’s and have them identified automatically.


About Tech B.

I am currently employed as a tech support rep for Frontier DSL internet and Dail-Up service. If you live on the East Coast and have Frontier or the old Verizon, you may have spoken with me at one point. I do side jobs programming and building things for people. I know Python better than any language in my toolbox. I can also develop Android Apps, which are Java based. Other languages include C , VB/VB.NET, some C#, PBASIC, Batch, Javascript, and some PHP. I love microcontrollers and interfacing with the outside world. I am currently working with Arduinos, which are amazing. Also I can work with the Basic Stamp family of microcontrollers; future development includes FPGA and embedded Linux. I was going to school, but have financial issues at the moment that are keeping me from the books. I plan on going back in the next couple semesters and finishing up my Associates in IT, then perusing a BS in computer science.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s