Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import praw
  2. import datetime
  3. import random
  4.  
  5. r = praw.Reddit(client_id='xxxxxxxxx',
  6. client_secret='xxxxxxxxx',
  7. password='xxxxxxxxx',
  8. user_agent='Jerry Thomas Rules Reporter 0.3 /u/cwinthrop',
  9. username='JeremiahPThomas')
  10.  
  11. rule_triggers = {'medical': '**No Medical Discussion:**',
  12. 'illegal': '**Illegal Activity:**',
  13. 'shitpost': '**Shitposting:**',
  14. 'purchase': '**Purchase Requests:**',
  15. 'advertising': '**Advertising:**',
  16. 'rhetoric': '**Anti-Alcohol Rhetoric:**'}
  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. def run():
  24. comments = r.subreddit('alcohol').comments(limit=50)
  25. for comment in comments:
  26. if 'jerry' in comment.body.lower():
  27. if comment.id not in open('newtest.txt','r').read().split('\n'):
  28. for trigger, rule in rule_triggers.items():
  29. if trigger in comment.body.lower() and comment.id not in open('newtest.txt','a+').read().split('\n'):
  30. print('Responding to comment!')
  31. open('newtest.txt', 'a').write(comment.id + '\n')
  32. message = random.choice(list(replies)) + rule
  33. comment.reply(message)
  34.  
  35.  
  36.  
  37. while True:
  38. try:
  39. run()
  40. except Exception as e:
  41. print(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement