Guest User

Untitled

a guest
Jun 9th, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. import praw
  2. import datetime
  3. import random
  4.  
  5. r = praw.Reddit(client_id='xxxxxxxxxx',
  6. client_secret='xxxxxxxxxxx',
  7. password='xxxxxxx',
  8. user_agent='Jerry Thomas Rules Reporter 0.3 /u/cwinthrop',
  9. username='JeremiahPThomas')
  10.  
  11. rule_triggers = {'medical': '**No Medical Discussion:** We do not care about your hangover lasting longer than you thought or your case of "Asian Flu',
  12. 'illegal': '**Illegal Activity:** If you want to ask how to do something that is obviously illegal, do not do it. We will not be giv',
  13. 'shitpost': '**Shitposting:** Making worthless, inflammatory, extraneous, or off-topic posts on thi subreddit is ShitPosting. This i',
  14. 'purchase': '**Purchase Requests:** *"Where do I buy _____?"* or *"Where can I get _____?"* and other such questions are not allowed',
  15. 'advertising': '**Advertising:** Posts offering or "suggesting" items for sale, (*whether alcohol related or not*) are prohibited.',
  16. 'rhetoric': '**Anti-Alcohol Rhetoric:** This is a subreddit dedicated to the enjoyment of alcohol. Anti-alcohol rhetoric should be...',
  17.  
  18. replies = {'If memory serves, that rule states...\n\n',
  19. 'I believe the rule in question states...\n\n',
  20. 'Unless I am mistaken, the rule you mean is...\n\n',
  21. 'Unless it has changed in the last few moments, that rule states...\n\n'}
  22.  
  23. reptail = '\n\n*This thread is now locked due to the above violation of the /r/alcohol rules. If the original poster is of the opinion this was done in error, they should contact the* [moderators](https://www.reddit.com/message/compose?to=%2Fr%2Falcohol) *immediately.*'
  24.  
  25. def run():
  26. comments = r.subreddit('alcohol').comments(limit=50)
  27. for comment in comments:
  28. if 'jerry' in comment.body.lower():
  29. if comment.id not in open('newtest.txt','r').read().split('\n'):
  30. for trigger, rule in rule_triggers.items():
  31. if trigger in comment.body.lower() and comment.id not in open('newtest.txt','a+').read().split('\n'):
  32. print('Responding to comment!')
  33. open('newtest.txt', 'a').write(comment.id + '\n')
  34. message = random.choice(list(replies)) + rule + reptail
  35. comment.reply(message)
  36. submission.mod.lock()
  37.  
  38. while True:
  39. try:
  40. run()
  41. except Exception as e:
Add Comment
Please, Sign In to add comment