Guest User

Untitled

a guest
Jan 30th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. import praw
  2. import time
  3. import datetime
  4.  
  5. r = praw.Reddit(client_secret='',
  6. client_id='',
  7. username='',
  8. user_agent='',
  9. password='')
  10.  
  11. # Get time
  12. currentSysTime = time.localtime()
  13. now = datetime.datetime.now(datetime.timezone.utc).timestamp()
  14. today = datetime.date.today()
  15.  
  16. log_post = (r.submission('93ypq5'))
  17.  
  18. subbie = 'ThanosDidNothingWrong' # sub to operate in
  19. moderators = r.subreddit(subbie).moderator()
  20. print("Bot for r/{}. Removes dead submissions.".format(subbie))
  21. print("Checking submissions...")
  22.  
  23. def TDNWRemoveBot():
  24. removal_reason = """Hi /u/{}, thanks for your submission to /r/thanosdidnothingwrong! Unfortunately it has been removed for the following reason(s):
  25.  
  26. ---
  27.  
  28. **RULE 2:**
  29.  
  30. - 2b. All posts 1 day old and below 50 karma will be automatically removed.
  31.  
  32. ---
  33.  
  34. *If you feel this was removed in error or are unsure about why this was removed then please [modmail us.](https://www.reddit.com/message/compose?to=%2Fr%2Fthanosdidnothingwrong)*
  35.  
  36.  
  37. ^^If ^^you ^^are ^^not ^^able ^^to ^^read ^^the ^^removal ^^reason ^^please ^^use ^^desktop ^^mode.
  38. """
  39. removed = []
  40. for submission in r.subreddit(subbie).new(limit=1000): #get 100 unapproved posts
  41. if submission.score < 50: # only if they are < 50
  42. age = now - submission.created_utc
  43. if age > int(86400): # if it's over 24 hours
  44. if submission not in removed:
  45. if submission.author not in moderators:
  46. submission.mod.remove() # remove submission
  47. removal_comment = submission.reply(removal_reason.format(submission.author))
  48. removal_comment.mod.distinguish(how='yes', sticky=True)
  49. removed.append(submission.permalink)
  50. print("reddit.com" + submission.permalink)
  51.  
  52. print(len(removed))
  53. removals = '\n\n * '.join(removed)
  54. r.subreddit(subbie).message('[Notification] Automated Removals - {}'.format(today),
  55. """
  56. The following submissions were removed for being low-effort after receiving less than 50 upvotes in twenty-four hours.
  57.  
  58. * {}
  59.  
  60. Total removals: {}
  61. """.format(removals, len(removed)))
  62.  
  63.  
  64. TDNWRemoveBot()
Add Comment
Please, Sign In to add comment