Skip to content

Instantly share code, notes, and snippets.

@idontwantcookies
Last active June 30, 2020 01:32
Show Gist options
  • Save idontwantcookies/e86f9eb94322274f6a40bda006cf9516 to your computer and use it in GitHub Desktop.
Save idontwantcookies/e86f9eb94322274f6a40bda006cf9516 to your computer and use it in GitHub Desktop.
shred comments on specific subreddits by writting gibberish and then deleting them
import string
import random
import praw
user_agent = "Subreddit comment shredder"
subs_to_delete_from = ['embarassing_sub_name1', 'embarassing_sub_name2']
reddit = praw.Reddit(
user_agent=user_agent,
client_id='YOUR_CLIENT',
client_secret='SECRET_CLIENT',
username='YOUR_USERNAME',
password='YOUR_PASSWORD'
)
user = reddit.user.me()
def gibberish(size):
return ''.join(random.choices(string.printable[:-5], k=size))
def scramble(comment):
comment.body = gibberish(random.randint(128, 512))
comment.save()
def shreddit(comment):
print(f'On r/{comment.subreddit}')
print(comment.body)
scramble(comment)
print(comment.body)
comment.delete()
print()
def delete_and_get_last_comment(after=None):
comments = list(user.comments.top(params={'after': after}))
print(f'Fetched {len(comments)} comments.')
if len(comments) == 0: return None
for c in comments:
if c.subreddit in subs_to_delete_from:
shreddit(c)
return c.name
def main():
c = None
while True:
c = delete_and_get_last_comment(after=c)
if c is None: break
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment