diff --git a/main.py b/main.py index 0fbe9dc..07e95b2 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,8 @@ import random import filecmp import shutil from check import * +from retweet import * + import authorization import PIL @@ -39,18 +41,21 @@ def main(): if (filecmp.cmp(dir+'img.jpg', dir+'imgold.jpg') == False) and (filecmp.cmp(dir+'img.jpg', dir+'nla1.jpg') == False) and (filecmp.cmp(dir+'img.jpg', dir+'nla2.jpg') == False): break - string = '' + + tweet_text = '' data = authorization.app.tag_urls(['https://imgur.com/'+id+'.jpg']) i=0 for i in range(5): - string = string+'#'+data['outputs'][0]['data']['concepts'][i]['name'].replace(" ", "")+" " + tweet_text = tweet_text+'#'+data['outputs'][0]['data']['concepts'][i]['name'].replace(" ", "")+" " tweetimg = open(dir+'img.jpg') - authorization.twitter.update_status_with_media(status = string, media = tweetimg) + authorization.twitter.update_status_with_media(status = tweet_text, media = tweetimg) - log_str = "https://imgur.com/"+id+".jpg "+string+"\n" + log_str = "https://imgur.com/"+id+".jpg "+tweet_text+"\n" log_file=open('log_file.txt', 'a') log_file.write(log_str) log_file.close() print log_str, + retweet() + time.sleep (60*30) \ No newline at end of file diff --git a/retweet.py b/retweet.py new file mode 100644 index 0000000..204e22f --- /dev/null +++ b/retweet.py @@ -0,0 +1,17 @@ +from twython import Twython, TwythonError +import authorization + +def retweet(): #retweet tweets with a set hashtag + search_results = authorization.twitter.search(q="#TwitterShitter", count=5) + try: + for tweet in search_results["statuses"]: + authorization.twitter.retweet(id = tweet["id_str"]) + log_str = "retweeted "+tweet["id_str"] + log_file=open('log_file.txt', 'a') + log_file.write(log_str) + log_file.close() + print log_str, + except TwythonError as e: + print e + + return \ No newline at end of file