Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.18 KB | None | 0 0
  1. import praw
  2. import datetime
  3. import random
  4.  
  5. r = praw.Reddit(client_id='xxxxxxxxx',
  6.                      client_secret='xxxxxxxxxxxx',
  7.                      password='xxxxxxxxx',
  8.                      user_agent='Jerry Thomas Rules Reporter 0.1 /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 Flush." And if you want to know if you were drugged or just really drunk, you were just really drunk. There are no medical experts here. If you are that concerned, we would **HIGHLY** suggest you take your medical questions to an actual doctor, instead of asking random strangers on the internet.',
  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 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, how to "beat" a breathalyzer, or any question concerning underage drinkers. This goes for giving said advice as well as asking for said advice.',
  13.                  'shitpost': '**Shitposting:** Making worthless, inflammatory, extraneous, or off-topic posts on thi subreddit is ShitPosting.
  14. This includes "drunk" posting, like *"Do you guys ever ____ while drunk/hungover?"* and *"How drunk do you like to get?"* as well as giving dangerous or ludicrous advice, like telling people to drink *isopropyl alcohol.*',
  15.                  'purchase': '**Purchase Requests:** *"Where do I buy _____?"* or *"Where can I get _____?"* and other such questions are not allowed. If you can post on /r/alcohol, you can use [Google](https://www.google.com).',
  16.                  'advertising': '**Advertising:** Posts offering or "suggesting" items for sale, (*whether alcohol related or not*) are prohibited. This includes begging for money/donations to an online fundraising campaign, as well as surveys.',
  17.                  'rhetoric': '**Anti-Alcohol Rhetoric:** This is a subreddit dedicated to the enjoyment of alcohol. Anti-alcohol rhetoric should be posted in /r/AlAnon, /r/Alcoholism, or /r/stopdrinking, instead.'}
  18.  
  19. replies = {'If memory serves, that rule states...\n\n',
  20.            'I believe the rule in question states...\n\n',
  21.            'Unless I am mistaken, the rule you mean is...\n\n',
  22.            'Unless it has changed in the last few moments, that rule states...\n\n'}
  23.  
  24. subreddit = r.subreddit('test')
  25. comments = subreddit.stream.comments()
  26.  
  27. for comment in comments:
  28.     text = comment.body
  29.     author = comment.author
  30.     stime = comment.created_utc
  31.     if 'jerry' in text.lower():
  32.         now = datetime.datetime.now(datetime.timezone.utc).timestamp()
  33.         difftime = now - stime
  34.         if difftime < 900:
  35.             for trigger, rule in rule_triggers.items():
  36.                 if trigger in text.lower():
  37.                     prelim = random.choice(list(replies))
  38.                     message = prelim + rule
  39.                     break
  40.                 else:
  41.                     message = 'null'
  42.  
  43.                 if message != 'null':
  44.                     comment.reply(message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement