From 549c3c2fef9e63262351513a5a20519892f72b26 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sun, 12 Jul 2015 13:06:23 -0700 Subject: initial commit --- unloved_tweets.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 unloved_tweets.py (limited to 'unloved_tweets.py') diff --git a/unloved_tweets.py b/unloved_tweets.py new file mode 100644 index 0000000..c206d18 --- /dev/null +++ b/unloved_tweets.py @@ -0,0 +1,36 @@ +import tweepy +import datetime +import math +from settings import * + +auth = tweepy.OAuthHandler(consumer_key, consumer_secret) +auth.set_access_token(access_token, access_token_secret) +api = tweepy.API(auth) + + +public_tweets = api.user_timeline() +for tweet in public_tweets: + lifetime = datetime.datetime.utcnow()-tweet.created_at + minutes = math.floor(lifetime.total_seconds() / 60) + + + engagements = 0 + engagements = engagements + tweet.favorite_count + tweet.retweet_count + if tweet.in_reply_to_status_id: + engagements = engagements + 1 + + if DEBUG: + print "--------" + print "%d engagements after %d minutes" % (engagements, minutes) + + if minutes<60 and minutes>=MINUTES_TO_LIVE and engagements==0: + if DEBUG: + print "DELETING " + str(tweet.id) + print tweet.text + + with open(DELETED_TWEETS_FILE, "a") as f: + f.write( tweet.text.encode('utf8') ) + f.write("\n\n") + + if not DEBUG: + api.destroy_status(tweet.id) -- cgit v1.2.3