Advertisement
Guest User

whatsgoingon.py

a guest
Mar 26th, 2015
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.47 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. '''
  3. Created on 11 Nov 2014
  4.  
  5. @author: CaptainParanoia
  6.  
  7. @license: MIT
  8. '''
  9.  
  10. import praw
  11. import time
  12. import numpy
  13. import datetime
  14. import logging
  15.  
  16. USER_AGENT = "WhatsGoingonHere v.2014-11-14 by /u/NewAustrian"
  17. THING_LIMIT = 1000
  18. SUB_BLACKLIST = ['t5_2s3qj', 't5_32yw1', 't5_2szgd','t5_34dqu','t5_34hgi', 't5_2wwh3', 't5_2zgoa']
  19. REPLY_TEXT = ["This is everywhere!", "Is this for real?", "The tips must flow!",
  20.              "Ah, Bitcoins. Nice.", "Wow. Big spender.", "Micropayments are really taking off.",
  21.              "I love the future.", "This is gentleman", "Is it Tuesday again?", "Spread the love.",
  22.              "That bot is very busy today.", "Let's hope the bot can deal with all the tips today. :)",
  23.              "You're keeping the bot busy.", "A tip a day keeps the Bearwhale away.",
  24.              "To the moon!", "Yeah, free money!", "Let it rain!", "Stay gentleman and keep on tipping.",
  25.              "Let it go viral!", "Whoa, what just happened here?", "This is VERY gentleman",
  26.              "The tipping bot really shows what the community can do.", "Ignore the haters and keep up the good work.",
  27.              "Keep up the good work.", "Gentleman, indeed", "Tipping makes me smile.",
  28.              "Nice to see more tips outside r/Bitcoin.", "Take that, /r/Bearwhale", "I really love this bot.",
  29.              "This gives me a warm and fuzzy feeling.", "Yeah, Bitcoin here we go!", "This. Bitcoin is here to stay!",
  30.              "Now try to do this with PayPal.", "Whoa! What just happened here?!", "ChangeTipBot for the win!",
  31.              "And there are people who want to ban the bot...", "Classic gentleman",
  32.              "Ah crypto currencies. I love them."]
  33. #REPLY_TEXT = ["Whoa, what just happened here?", "Whoa! What just happened here?!", "How can I do this?", "How does this work?",
  34. #    "I see this everywhere but how does it work?", "Can I do this as well?"]
  35.  
  36. RESPONSE_RATE = 0.025
  37. PARENT_RATE = 0.2
  38.  
  39. if __name__ == '__main__':
  40.     logging.basicConfig(filename='/home/maix/usr/log/whatsgoingon.log', level=logging.INFO)
  41.     logging.info('Started: ' + str(datetime.datetime.now()))
  42.     time.sleep(numpy.random.randint(0,600))
  43.     r = praw.Reddit(user_agent=USER_AGENT)
  44.     r.login('JennyCherry18', 'REDACTED')
  45.     logging.info('Login')
  46.     user_name = "changetip"
  47.     user = r.get_redditor(user_name)
  48.  
  49.    
  50.     already_done = []
  51.    
  52.     comments = user.get_comments(limit=THING_LIMIT)
  53.     for comment in comments:
  54.         if comment.subreddit_id not in SUB_BLACKLIST and comment.id not in already_done:
  55.             if numpy.random.random() < RESPONSE_RATE:
  56.                 logging.info(comment)
  57.                 text = numpy.random.choice(REPLY_TEXT, 1)[0]
  58.                 try:
  59.                     if numpy.random.random() > PARENT_RATE:
  60.                         comment.reply(text)
  61.                         logging.info("REPLIED TO BOT: " + text)
  62.                     else:
  63.                         parent = r.get_info(thing_id=comment.parent_id)
  64.                         parent.reply(text)
  65.                         logging.info("REPLIED TO BOT: " + text)
  66.                     time.sleep(90 + numpy.random.randint(0,120))
  67.                 except praw.errors.RateLimitExceeded as err:
  68.                     logging.exception("RateLimitExceeded")
  69.                     time.sleep(err.sleep_time + 10)
  70.                    
  71.             already_done.append(comment.id)
  72.        
  73.    
  74.     logging.info("Completed: " + str(datetime.datetime.now()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement