Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import datetime
- import random
- r = praw.Reddit(client_id='xxxxxxxxx',
- client_secret='xxxxxxxxx',
- password='xxxxxxxxx',
- user_agent='Jerry Thomas Rules Reporter 0.3 /u/cwinthrop',
- username='JeremiahPThomas')
- rule_triggers = {'medical': '**No Medical Discussion:**',
- 'illegal': '**Illegal Activity:**',
- 'shitpost': '**Shitposting:**',
- 'purchase': '**Purchase Requests:**',
- 'advertising': '**Advertising:**',
- 'rhetoric': '**Anti-Alcohol Rhetoric:**'}
- 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'}
- 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
- comment.reply(message)
- while True:
- try:
- run()
- except Exception as e:
- print(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement