aboutsummaryrefslogtreecommitdiffstats
path: root/unloved_tweets.py
diff options
context:
space:
mode:
authorAdam Mathes <amathes@gmail.com>2015-07-12 13:06:23 -0700
committerAdam Mathes <amathes@gmail.com>2015-07-12 13:06:23 -0700
commit549c3c2fef9e63262351513a5a20519892f72b26 (patch)
tree73b32d0700b3f38724fd8b381fdc376569ed798c /unloved_tweets.py
initial commit
Diffstat (limited to 'unloved_tweets.py')
-rw-r--r--unloved_tweets.py36
1 files changed, 36 insertions, 0 deletions
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)