Skip to content

Instantly share code, notes, and snippets.

@PythonCoderAS
Last active January 9, 2018 00:28
Show Gist options
  • Select an option

  • Save PythonCoderAS/6cf48f0f53116fd1802557de95da92a9 to your computer and use it in GitHub Desktop.

Select an option

Save PythonCoderAS/6cf48f0f53116fd1802557de95da92a9 to your computer and use it in GitHub Desktop.
import praw
import datetime
import time
import prawcore
u = '' #username
p = '' #password
c_id = '' #client_id
c_s = '' #client secret
subreddit = '' #put in subreddit name
reddit = praw.Reddit(username = u, password = p, client_id = c_id, client_secret = c_s, user_agent = 'Karma/Hour Remover v 1.0')
def remove(submission):
if (datetime.datetime.now() - datetime.datetime.fromtimestamp(submission.created)).seconds >= 3600 and submission.score < 10:
comment = submission.reply('Your submission has been removed because it had less than 10 karma in 1 hour.')
try:
comment.distinguish(how=’yes’, sticky=True)
submission.mod.remove()
except prawcore.exceptions.Forbidden:
print('Check your permissions. Bot cannot distinguish/remove. Check if moderator with post privleges. Exiting...')
input('Press enter to exit...')
exit()
def main(reddit):
while True:
for sub in reddit.subreddit(str(subreddit)).new():
remove(sub)
time.sleep(60) #waits a minute before re-sifting through posts
if __name__ == '__main__':
main(reddit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment