Last active
August 29, 2015 14:03
-
-
Save joemsak/4e56adeeae0fb0ff5ca9 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
from twython import Twython | |
import time | |
twitter = Twython('consumer_key', 'consumer_secret', 'oauth_key', 'oauth_secret') | |
img = open('album_artwork.jpeg', 'rb') | |
filepath = 'tmp/replied_status_ids.txt' | |
while True: | |
mention = twitter.get_mentions_timeline()[0] | |
status_id = mention['id'] | |
statuses = open(filepath).read() # read the file here | |
if str(status_id) not in statuses: | |
screen_name = '@' + mention['user']['screen_name'] | |
twitter.update_status_with_media(status = screen_name, | |
media = img, | |
in_reply_to_status_id = status_id) | |
with open(filepath, 'a') as database: # open the file a second time for writing | |
database.write(str(status_id) + "\n") | |
else: | |
print 'We replied to this one already!' | |
time.sleep(60) # 1 minute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment