Well, lets just say that twitter is probably the best service of its type, let alone the only. And XChat is my favorite irc client. So the best thing would be to combine the two. And lone and behold it has happened. Thanks to a thread in the WyldRyde.org forums I have found something that I have been looking for. The search has finally ended. Here is the code and thanks to author Ryan Paul.
#!/usr/bin/env python import xchat, urllib2, urllib, base64 # Describe the plug-in metadata for XChat __module_name__ = "Twitter Plug-in" __module_version__ = "1.0" __module_description__ = "Send Twitter status updates from XChat" # Twitter username and password USERNAME = "yourusernamehere" PASSWORD = "yourpasswordhere" def tweet(words, word_eol, userdata): # Generate authentication string to send in HTTP request header auth = base64.encodestring("%s:%s" % (USERNAME, PASSWORD)).strip() # Display the tweet message in the active IRC channel xchat.command("me tweets: %s" % " ".join(words[1:])) # Transmit the status update message to Twitter urllib2.urlopen(urllib2.Request("http://twitter.com/statuses/update.json", urllib.urlencode({"status":" ".join(words[1:])}), {"Authorization": "Basic %s" % auth})) # Associate the tweet function with the /tweet command in XChat xchat.hook_command("tweet", tweet, help="/tweet <message>")
Installation Instructions:
- Copy the above code into a notepad document.
- Insert your twitter username and password in the # Twitter username and password section
- Save to a location on your computer with a file name such as tweet.py. You can make the file name be anything but you MUST have a .py extension. Other wise the script wont work. REMEMBER THE FILE PATH
- Download the latest version of python from Python.org.
- Run the python installer and then start XChat.
- From the XChat drop down list choose Load File or Script…
- Navigate to the file and double click.
- In XChat type /tweet <your tweet here> and then you are ready
- If you get an error message make sure to check you credentials.
Original Post at: http://arstechnica.com/journals/linux.ars/2007/08/29/send-twitter-updates-from-xchat-using-python
– Jerry Smith



One Comment
great, works fine via xchat!!!!