Showing posts with label irc. Show all posts
Showing posts with label irc. Show all posts

Wednesday, June 25, 2008

Recent Hacks: irc2wiki.pl and xchat-nick-pidgin-status.py

The Mono a11y team has weekly iteration meetings in IRC, and we post the logs to the Mono wiki. Our version of MediaWiki doesn't automatically prettify IRC logs, so for awhile I was using Jamie Zawinski's irc2html.pl to create HTML tables. Today I hacked it up to produce MediaWiki tables instead. I call it irc2wiki.pl. Fixes welcome (or better suggestions).

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)

Sunday, June 24, 2007

Name has been changed to protect the creepy

--- Log opened Sun Jun 24 09:18:16 2007
09:18 -!- Irssi: Starting query in GIMPNet with creepy_loser
09:18 [creepy_loser] hi
09:18 [creepy_loser] sandy
09:18 [sandy|away] hey
09:18 [sandy|away] what's up?
09:18 [creepy_loser] fine
09:18 [creepy_loser] :)
09:18 [creepy_loser] snd you
09:18 [creepy_loser] and u
09:19 [sandy|away] good, what can I help you with?
09:19 [creepy_loser] hmm
09:19 [creepy_loser] you should write me where are u from ?
09:19 [sandy|away] why?
09:20 [creepy_loser] for be your friend maybe
09:20 [sandy|away] hmm...do you know that I'm a dude?
09:20 [sandy|away] full name is "Sanford"
09:21 [creepy_loser] where is sanford ?
09:21 [sandy|away] I'm Sanford
09:21 [sandy|away] that's my name
09:21 [sandy|away] sandy is a nickname
09:21 [creepy_loser] :)
09:21 [creepy_loser] where are u sanford ?
09:21 * sandy|away sighs
09:22 [creepy_loser] my dude friend :)
09:22 [sandy|away] so I'm going to ignore you now
09:22 [sandy|away] just fyi
09:22 [creepy_loser] and i fuck you now
09:22 [creepy_loser] :)
09:24 -!- creepy_loser [~creepy_losers_computer@creepy.losers.ip.address] has quit []
--- Log closed Sun Jun 24 09:24:37 2007

EDIT: The log didn't pick up the fact that he tried to query for my avatar (I don't have one). This is a private message from somebody who was in #gnome briefly, where I was lurking.