Also, I now live on IRC. Some people prefer to get me through IM, so I always have Pidgin running, but my online presence is mostly reflected in my IRC nick. I'm forgetful, so I kept noticing that I was "available" in Pidgin even though my IRC nick was "sandy|lunch", or that when I changed my nick from "sandy|brb" to "sandy" my Pidgin status would stay the same. I decided to automate that shit. Based on a bunch of useful code from Arstechnica's Ryan Paul, I present to you my first xchat plugin, xchat-nick-pidgin-status.py:
#!/usr/bin/env python
# Sets Pidgin status from XChat nick, assuming you use a style like:
# mynick => Available (status "Workin")
# mynick|busy => Away (status "busy")
# Hobbled together by Sandy Armstrong from code
# written by Ryan Paul (segphault) of Ars Technica:
# http://arstechnica.com/reviews/apps/pidgin-2-0.ars/4
# http://arstechnica.com/journals/linux.ars/2007/08/29/send-twitter-updates-from-xchat-using-python
import xchat, dbus
# Describe the plug-in metadata for XChat
__module_name__ = "Pidgin Status Plug-in"
__module_version__ = "1.0"
__module_description__ = "Set Pidgin status according to XChat nick"
# Specify status ID values
STATUS_AVAILABLE = 2
STATUS_AWAY = 5
def nick(words, word_eol, userdata):
# Get new nick
if len(words) < 2:
return None
new_nick = words[1]
# Check for status
pipe_index = new_nick.find("|")
if pipe_index > 0 and pipe_index < len(new_nick):
message = new_nick[pipe_index + 1:]
# set away with status message
set_status("", STATUS_AWAY, message)
else:
# set available
set_status("", STATUS_AVAILABLE, "Workin")
def set_status(name, kind, message):
# Create a new saved status with the specified name and kind
status = purple.PurpleSavedstatusNew(name, kind)
# Associate the specified availability message with the new saved status
purple.PurpleSavedstatusSetMessage(status, message)
# Activate the new saved status
purple.PurpleSavedstatusActivate(status)
# Initiate a connection to the Session Bus
bus = dbus.SessionBus()
# Associate Pidgin's D-Bus interface with Python objects
obj = bus.get_object(
"im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
# Associate the nick function with the /nick command in XChat
xchat.hook_command("nick", nick)
5 comments:
This is a really bad idea - not the plugin in itself, but what it relies on. It is generally frowned upon to have your status in your nick on IRC.
I'd recommend using the AWAY feature of the IRC protocol (/away [reason] in most clients) instead.
@some visitor: In the IRC communities I frequent, the practice of including status in your nick is very common. Even if I were to use the AWAY feature (which nobody ever seems to use), I would continue to change my nick.
It should be easy to modify the plugin to respond to the /away command, of course.
Why don't you use pidgin for IRC?
@anonymous: Because Pidgin is a horrible IRC client. Also, my *real* IRC client is an irssi instance running on my home server, so that I will always be connected (good for making logs, etc). I can connect to it with any IRC client I like using irssi_proxy. But Pidgin, being a horrible IRC client, tells irssi to close all channels when I quit, defeating the whole point of my setup.
Coincidentally, Ian Weller recently sent me a patch for irclog2html.py to support producing MediaWiki markup.
I was wondering then (and am still wondering now) whether the script should do some sort of quoting to prevent random things said by people on IRC confusing the MediaWiki parser. I'm not myself familiar with MediaWiki.
Post a Comment