Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. import praw
  2. import datetime
  3. import random
  4.  
  5. r = praw.Reddit(client_id='xxxxxxxx',
  6. client_secret='xxxxxxxxxxxxxx',
  7. password='xxxxx',
  8. user_agent='Jerry Thomas Rules Reporter 0.3 /u/cwinthrop',
  9. username='JeremiahPThomas')
  10.  
  11. rule_triggers = {
  12. 'medical': '**Medical Discussion:**\n\nWe don\'t care about your hangover (*or lack of hangover*), how you throw up every time you drink, or your case of \"Asian Flush.\" We can\'t tell you why a certain alcohol makes you sick, or how much of it will take to get you drunk. And if you want to know if you were drugged or just really drunk, you were just really drunk.\n\nThere are no medical experts here. If you\'re that concerned, we would **HIGHLY** suggest you take your medical questions to an actual doctor, instead of asking random strangers on the internet.',
  13. 'underage': '**Underage Drinking:**\n\n/r/alcohol is a subreddit for the discussion of Alcohol. As such, this subreddit follows the [international laws governing minimum required age limits on drinking](https://www.reddit.com/r/alcohol/wiki/age\#wiki_list_of_minimum_age_limits_by_country).\n\nThe Moderators make every effort to verify the age and geographic location of users in the subreddit. However, lacking exact data, they must assume an underage user is located in the United States (*statistically the most represented country in this subreddit*), where the legal minimum drinking age is 21.',
  14. 'illegal': '**Illegal Activity:**\n\nIf you want to ask how to do something that\'s obviously illegal, don\'t. We will not be giving advice on how to sneak alcohol into concerts or sporting events, how to fake your way past any sort of drug or alcohol test (*including anything dealing with the ETG test*), how to \"beat\" a breathalyzer, or any question concerning [underage drinkers](https://www.reddit.com/r/alcohol/wiki/age).',
  15. 'shitpost': '**Shitposting:**\n\nA person who makes worthless or inflammatory posts on a subreddit is a ShitPoster. This includes \"drunk\" posting, like *\"Do you guys ever ____ while drunk/hungover?\"* and *\"How drunk do you like to get?\"* as well as posting memes, trolling, brigading, and giving dangerous or ludicrous advice, like telling people to drink *isopropyl alcohol.* If you *must* disagree with someone, be *civil* about it. Harrassing other users will not be tolerated. Remember, the [rules of Reddiquette](https://www.reddit.com/wiki/reddiquette) always apply.',
  16. 'purchase': '**Purchase/Valuation Requests:**\n\n*\"Where do I buy _____?\"* *\"Where can I get _____?\"* *\"What\'s this bottle worth?\"* and other such questions are not allowed. If you can post on /r/alcohol, you can use [Google](https://www.google.com).',
  17. 'advertising': '**Advertising:**\n\nPosts offering or \"suggesting\" any items for sale, including third party \"free\" commercial products are prohibited. This includes begging for money/donations to an online fundraising campaign, as well as surveys and apps.',
  18. 'rhetoric': '**Anti-Alcohol Rhetoric:**\n\nThis is a subreddit dedicated to the enjoyment of alcohol. Posts complaining about how you don\'t like alcohol, or wanting to know if you are (*or are likely to become*) an alcoholic, should be posted in /r/AlAnon, /r/Alcoholism, or /r/stopdrinking, instead. Additionally, **NOBODY** in this subreddit is interested in your \"Alcohol Addiction Treatment\" spam.'}
  19.  
  20. flair_triggers = {
  21. 'medical': 'Rule: Medical Discussion',
  22. 'underage': 'Rule: Underage Drinking',
  23. 'illegal': 'Rule: Illegal Activity',
  24. 'shitpost': 'Rule: Shitposting',
  25. 'purchase': 'Rule: Purchase/Valuation Request',
  26. 'advertising': 'Rule: Advertising',
  27. 'rhetoric': 'Rule: Anti-Alcohol Rhetoric'}
  28.  
  29. 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.*'
  30.  
  31. def run():
  32. comments = r.subreddit('alcohol').comments(limit=50)
  33. for comment in comments:
  34. if 'jerry' in comment.body.lower():
  35. if comment.id not in open('newtest.txt','r').read().split('\n'):
  36. for trigger, rule in rule_triggers.items():
  37. if trigger in comment.body.lower() and comment.id not in open('newtest.txt','a+').read().split('\n'):
  38. mods = list(r.subreddit('alcohol').moderator())
  39. if comment.author in mods:
  40. print('Responding to comment!')
  41. open('trigger.txt', 'a').write(trigger + '\n')
  42. open('newtest.txt', 'a').write(comment.id + '\n')
  43. message = rule + reptail
  44. submission = comment.submission
  45. comment.reply(message)
  46. submission.mod.lock()
  47. for trigger, flair in flair_triggers.items():
  48. choices = submission.flair.choices()
  49. template_id = next(x for x in choices
  50. if x['flair_text_editable'])['flair_template_id']
  51. print('Setting flair: ', flair)
  52. submission.flair.select(template_id, flair)
  53.  
  54. while True:
  55. try:
  56. run()
  57. except Exception as e:
  58. print(str(e))
  59. open('faillog.txt', 'a').write(str(e) + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement