Friday, April 4, 2008

Update Kopete with Twitter Status

I love how twitter can update my facebook status but it would be even better for it to update my away message for gchat and aim while on kopete. The most important finding for me was the dcop command for kde programs. The usage of the command is as follows:

dcop kopete KopeteIface setAway "away message" false

Once I figured that out, I surfed around the Twitter API for my favorite scripting language wrapper, python. So after install python-twitter, I created a script that will check my Twitter status every minute and update by away message for kopete.

import twitter, os, time

while True:
api = twitter.Api()
user = ""
statuses = api.GetUserTimeline(user)
stat = [s.text for s in statuses]
stat = str(stat[0])
os.system("dcop kopete KopeteIface ...
... setAway \"" + stat + "\" false")

So just have this script load at start up and your away message will change even when you aren't there. I know this isn't the best way to code it, but it works :P

1 comment:

  1. id change it to every 5 minutes to free up stress on the twitter servers. other scripts have already strayed away from the every minute update, apparently they were bringing the site to a crawl. but, nice work, gl and hf.