Skip to content

Instantly share code, notes, and snippets.

@storborg
Created June 15, 2009 23:14
Show Gist options
  • Save storborg/130417 to your computer and use it in GitHub Desktop.
Save storborg/130417 to your computer and use it in GitHub Desktop.
"""
Cute twitter bot to twitter pretty flickr photos and unicode characters.
"""
import flickr, random, urllib
from twitter import Twitter
flickr.API_KEY = 'FILL ME IN'
username = 'prettier'
password = 'FILL ME IN'
chars = ['&#x2764', '&#x263c', '&#x2600', '&#x2606', '&#x2605', '&#x2766',
'&#x2741', '&#x2740', '&#x273f', '&#x273e', '&#x273d', '&#x273a',
'&#x2735', '&#x263a', '&#x263b', '&#x266c', '&#x266b', '&#x266a']
# pick a flickr photo from the 20 most interesting photos right now
photo = random.choice(flickr.interestingness()[20:])
url = photo.getURL(urlType='source')
print "picked photo %s" % url
# make a tinyurl for it
tu = urllib.urlopen('http://tinyurl.com/api-create.php?url=%s' % url).read()
# pick some cute unicode characters to toss in there
tweet = ' '.join([random.choice(chars) for _ in range(4)] + [tu])
print "tweeting '%s'" % tweet
twitter = Twitter(username, password)
twitter.statuses.update(status=tweet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment