Distingused / gilded ignore option.

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

10
.gitignore vendored

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

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

@ -2,6 +2,7 @@
# Login details for Reddit. Fill out if you don't wish
# 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 =
password =
@ -42,3 +43,9 @@ trial_run = True
# Don't delete but *do* edit, could prove... interesting to see a comment
# with 5000 upvotes and it's just a lorem ipsum!
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')
edit_only = config.getboolean('main', 'edit_only')
item = config.get('main', 'item')
whitelist_distinguished = config.getboolean('main', 'whitelist_distinguished')
whitelist_gilded = config.getboolean('main', 'whitelist_gilded')
_user = config.get('main', 'username')
_pass = config.get('main', 'password')
@ -73,7 +74,8 @@ def login(user=None, password=None):
except RateLimitExceeded as 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:
print("Logged in as {user}".format(user=r.user))
@ -118,28 +120,35 @@ for thing in things:
thing.id in whitelist_ids:
continue
if not trial_run:
if clear_vote:
thing.clear_vote()
if isinstance(thing, Submission):
if verbose:
print(u'Deleting submission: #{id} {url}'.format(
id=thing.id,
url=thing.url)
)
elif isinstance(thing, Comment):
replacement_text = get_sentence()
if verbose:
msg = '/r/{3}/ #{0} with:\n\t"{1}" to\n\t"{2}"'.format(
thing.id,
sub(b'\n\r\t', ' ', thing.body[:78].encode('utf-8')),
replacement_text[:78],
thing.subreddit
)
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()
if trial_run:
# Don't actually perform any actions
next
if whitelist_distinguished and item.distinguished:
next
if whitelist_gilded and thing.gilded:
next
if clear_vote:
thing.clear_vote()
if isinstance(thing, Submission):
if verbose:
print(u'Deleting submission: #{id} {url}'.format(
id=thing.id,
url=thing.url)
)
elif isinstance(thing, Comment):
replacement_text = get_sentence()
if verbose:
msg = '/r/{3}/ #{0} with:\n\t"{1}" to\n\t"{2}"'.format(
thing.id,
sub(b'\n\r\t', ' ', thing.body[:78].encode('utf-8')),
replacement_text[:78],
thing.subreddit
)
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