Created
June 15, 2009 23:14
-
-
Save storborg/130417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 = ['❤', '☼', '☀', '☆', '★', '❦', | |
'❁', '❀', '✿', '✾', '✽', '✺', | |
'✵', '☺', '☻', '♬', '♫', '♪'] | |
# 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