Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import datetime
- import random
- r = praw.Reddit(client_id='xxxxxxxxxx',
- client_secret='xxxxxxxxxxx',
- password='xxxxxxx',
- user_agent='Jerry Thomas Rules Reporter 0.3 /u/cwinthrop',
- username='JeremiahPThomas')
- rule_triggers = {'medical': '**No Medical Discussion:** We do not care about your hangover lasting longer than you thought or your case of "Asian Flu',
- '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',
- 'shitpost': '**Shitposting:** Making worthless, inflammatory, extraneous, or off-topic posts on thi subreddit is ShitPosting. This i',
- 'purchase': '**Purchase Requests:** *"Where do I buy _____?"* or *"Where can I get _____?"* and other such questions are not allowed',
- 'advertising': '**Advertising:** Posts offering or "suggesting" items for sale, (*whether alcohol related or not*) are prohibited.',
- 'rhetoric': '**Anti-Alcohol Rhetoric:** This is a subreddit dedicated to the enjoyment of alcohol. Anti-alcohol rhetoric should be...',
- replies = {'If memory serves, that rule states...\n\n',
- 'I believe the rule in question states...\n\n',
- 'Unless I am mistaken, the rule you mean is...\n\n',
- 'Unless it has changed in the last few moments, that rule states...\n\n'}
- 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.*'
- def run():
- comments = r.subreddit('alcohol').comments(limit=50)
- for comment in comments:
- if 'jerry' in comment.body.lower():
- if comment.id not in open('newtest.txt','r').read().split('\n'):
- for trigger, rule in rule_triggers.items():
- if trigger in comment.body.lower() and comment.id not in open('newtest.txt','a+').read().split('\n'):
- print('Responding to comment!')
- open('newtest.txt', 'a').write(comment.id + '\n')
- message = random.choice(list(replies)) + rule + reptail
- comment.reply(message)
- submission.mod.lock()
- while True:
- try:
- run()
- except Exception as e:
Add Comment
Please, Sign In to add comment