Carlos Scheidegger
By: a guest | Jun 2nd, 2009 | Syntax:
None | Size: 0.81 KB | Hits: 86 | Expires: Never
#!/usr/bin/env python
# This dumb script is public domain. Have fun with it! If it pees on
# your carpet, it's not my fault!
# You'll need http://code.google.com/p/python-twitter/, and this
# script currently uses a patch that's not incorporated in the
# trunk. If you feel inclined, just hack the source to catch a
# urllib2.HTTPError in the method GetUser().
import twitter
import sys
api = twitter.Api(username='YOUR_USERNAME_GOES_HERE',
password='YOUR_PASSWORD_GOES_HERE')
msg = sys.argv[1:]
at_user = None
if msg[0].startswith('@'):
try:
at_user = api.GetUser(msg[0][1:]).GetId()
except TwitterError:
sys.stderr.write("Could not find user %s. Ignoring.\n" % msg[0][1:])
msg = msg[1:]
api.PostUpdate(" ".join(msg), in_reply_to_status_id=at_user)