From 9a186c098884603194fc665a15fdace1f527b97a Mon Sep 17 00:00:00 2001 From: David Trail Date: Tue, 20 Mar 2012 09:51:32 +0000 Subject: [PATCH] Added some new abilities --- shreddit | 26 ++++++++++++++++++-------- shreddit.cfg | 4 ++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/shreddit b/shreddit index c46b075..0439985 100755 --- a/shreddit +++ b/shreddit @@ -11,6 +11,8 @@ days = config.getint('main', 'days') whitelist = config.get('main', 'whitelist') sort = config.get('main', 'sort') verbose = config.getboolean('main', 'verbose') +clear_vote = config.getboolean('main', 'clear_vote') +item = config.get('main', 'item') r = reddit.Reddit(user_agent="Shreddit-PRAW") # add user: / pswd: to the [reddit] config section @@ -29,11 +31,19 @@ whitelist = [y.strip().lower() for y in whitelist.split(',')] if verbose: print "Keeping messages from subreddits %s" % ', '.join(whitelist) -for comment in r.user.get_comments(limit=None, sort=sort): - if str(comment.subreddit).lower() in whitelist: - next - now_time = datetime.fromtimestamp(comment.created) - if now_time < before_time: - if verbose: - print 'Deleting: [%s]: "%s"' % (comment.subreddit, comment.body[:20]) - comment.delete() +things = [] +if item == "comments": + things = r.user.get_comments(limit=None, sort=sort) +elif item == "submissions": + things = r.user.get_submissions(limit=None, sort=sort) + +for thing in things: + if str(thing.subreddit).lower() in whitelist: + continue + now_time = datetime.fromtimestamp(thing.created) + if now_time < before_time: + if verbose: + print 'Deleting: [%s]: "%s"' % (thing.subreddit, thing.body[:20]) + if clear_vote: + thing.clear_vote() + thing.delete() diff --git a/shreddit.cfg b/shreddit.cfg index 548d161..300c052 100644 --- a/shreddit.cfg +++ b/shreddit.cfg @@ -3,7 +3,7 @@ [main] # How many days of comments you want to keep -days = 7 +days = 3 # Options: new, top, controversial, more? sort = new @@ -17,7 +17,7 @@ clear_vote = True # Options: comments, submissions # Deletes either everything you've submitted # or every comment in your history. -items = comments +item = comments # Anything in this list won't be deleted, coma delimited # spaces should work as .strip() is called after splitting