Skip navigation

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:

  1. Copy the above code into a notepad document.
  2. Insert your twitter username and password in the # Twitter username and password section
  3. 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
  4. Download the latest version of python from Python.org.
  5. Run the python installer and then start XChat.
  6. From the XChat drop down list choose Load File or Script…
  7. Navigate to the file and double click.
  8. In XChat type /tweet <your tweet here> and then you are ready
    1. 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

  1. great, works fine via xchat!!!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.