Distingused / gilded ignore option.

pull/18/head
David Trail 10 years ago
parent 20d2b850a9
commit e968036137

10
.gitignore vendored

@ -1,7 +1,9 @@
*.cfg *.cfg
*.pyc *.pyc
.idea/ .idea
bin/ bin
include/ include
lib/ lib
env
shreddit.conf
__pycache__/ __pycache__/

@ -0,0 +1,3 @@
[DEFAULT]
user =
pswd =

@ -2,6 +2,7 @@
# Login details for Reddit. Fill out if you don't wish # Login details for Reddit. Fill out if you don't wish
# to be prompted for a login every time you run Shreddit. # to be prompted for a login every time you run Shreddit.
### NOTE: This may be deprecated as you can specify in praw.ini instead
username = username =
password = password =
@ -42,3 +43,9 @@ trial_run = True
# Don't delete but *do* edit, could prove... interesting to see a comment # Don't delete but *do* edit, could prove... interesting to see a comment
# with 5000 upvotes and it's just a lorem ipsum! # with 5000 upvotes and it's just a lorem ipsum!
edit_only = True edit_only = True
# Ignore distinguished comments.
ignore_distinguished = True
# ignore gilded (gold) comments
whitelist_gilded = True

@ -53,7 +53,8 @@ clear_vote = config.getboolean('main', 'clear_vote')
trial_run = config.getboolean('main', 'trial_run') trial_run = config.getboolean('main', 'trial_run')
edit_only = config.getboolean('main', 'edit_only') edit_only = config.getboolean('main', 'edit_only')
item = config.get('main', 'item') item = config.get('main', 'item')
whitelist_distinguished = config.getboolean('main', 'whitelist_distinguished')
whitelist_gilded = config.getboolean('main', 'whitelist_gilded')
_user = config.get('main', 'username') _user = config.get('main', 'username')
_pass = config.get('main', 'password') _pass = config.get('main', 'password')
@ -73,7 +74,8 @@ def login(user=None, password=None):
except RateLimitExceeded as e: except RateLimitExceeded as e:
raise RateLimitExceeded("You're doing that too much.", e) raise RateLimitExceeded("You're doing that too much.", e)
login(user=_user, password=_pass) if not r.is_logged_in():
login(user=_user, password=_pass)
if verbose: if verbose:
print("Logged in as {user}".format(user=r.user)) print("Logged in as {user}".format(user=r.user))
@ -118,28 +120,35 @@ for thing in things:
thing.id in whitelist_ids: thing.id in whitelist_ids:
continue continue
if not trial_run: if trial_run:
if clear_vote: # Don't actually perform any actions
thing.clear_vote() next
if isinstance(thing, Submission): if whitelist_distinguished and item.distinguished:
if verbose: next
print(u'Deleting submission: #{id} {url}'.format( if whitelist_gilded and thing.gilded:
id=thing.id, next
url=thing.url)
) if clear_vote:
elif isinstance(thing, Comment): thing.clear_vote()
replacement_text = get_sentence() if isinstance(thing, Submission):
if verbose: if verbose:
msg = '/r/{3}/ #{0} with:\n\t"{1}" to\n\t"{2}"'.format( print(u'Deleting submission: #{id} {url}'.format(
thing.id, id=thing.id,
sub(b'\n\r\t', ' ', thing.body[:78].encode('utf-8')), url=thing.url)
replacement_text[:78], )
thing.subreddit elif isinstance(thing, Comment):
) replacement_text = get_sentence()
if edit_only: if verbose:
print('Editing {msg}'.format(msg=msg)) msg = '/r/{3}/ #{0} with:\n\t"{1}" to\n\t"{2}"'.format(
else: thing.id,
print('Editing and deleting {msg}'.format(msg=msg)) sub(b'\n\r\t', ' ', thing.body[:78].encode('utf-8')),
thing.edit(replacement_text) replacement_text[:78],
if not edit_only: thing.subreddit
thing.delete() )
if edit_only:
print('Editing {msg}'.format(msg=msg))
else:
print('Editing and deleting {msg}'.format(msg=msg))
thing.edit(replacement_text)
if not edit_only:
thing.delete()

Loading…
Cancel
Save