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.