Advertisement
Guest User

Untitled

a guest
May 14th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. import praw
  2. import os
  3. import re
  4. import random
  5.  
  6. if not os.path.isfile("posts_replied_to.txt"):
  7. posts_replied_to = []
  8. else:
  9. with open("posts_replied_to.txt", "r") as f:
  10. posts_replied_to = f.read()
  11. posts_replied_to = posts_replied_to.split("\n")
  12.  
  13. #load stats file into usable variables.
  14. #you will have to manually create this file first, it's buggy otherwise
  15. with open('WallStats.txt', 'r') as inFile:
  16. stats = inFile.read().split('\n')
  17. height = float(stats.pop())
  18. length = float(stats.pop())
  19. percentage = float(stats.pop())
  20. numBricks = int(stats.pop())
  21.  
  22. #init bot
  23. reddit = praw.Reddit(user_agent='foobar',
  24. client_id='yourclientid', client_secret='yoursecretkey',
  25. username='YourBot', password='expunged')
  26.  
  27. print(reddit.user.me())
  28. print("... IS ACTIVE!!!")
  29.  
  30. #subreddits that your bot will interact with
  31. subreddit = reddit.subreddit("the_donald+DrainTheSwamp+100_Legs_Over_Texas+tretki")
  32.  
  33. for comment in subreddit.stream.comments():
  34. if(re.search("ludicrous speed", comment.body, re.IGNORECASE) or re.search("ludicrous brick", comment.body, re.IGNORECASE) or re.search("ludacris speed", comment.body, re.IGNORECASE) or re.search("ludacris brick", comment.body, re.IGNORECASE)) and not comment.author==reddit.user.me() and comment.fullname not in posts_replied_to:
  35. #increase stats!
  36. ludicrousBricks = random.randrange(5,20)
  37. numBricks += ludicrousBricks
  38. percentage += random.uniform(0,0.001)
  39. length += random.uniform(0,0.09)
  40. height += random.uniform(0,0.005)
  41.  
  42. print("Readying LUDICROUS shitpost " + str(numBricks) + "!") #message to console
  43. #build the comment!
  44. reply_string = "#[LUDICROUS SPEED?!](https://youtu.be/oApAdwuqtn8)\n\n#*THAT'S LUDICROUS!*\n\n**SOMEONE GET THIS BATSHIT INSANE PATRIOT " + str(ludicrousBricks) +" BRICKS!!!**\n\n*why,* you ask? BECAUSE THIS **PATRIOT** WILL USE THEM TO **SOFTEN THEIR FASTER-THAN-LIGHT CRASH LANDING** at the **U.S./MEXICO BORDER!!!!!**\n\n**THAT'S " + str(numBricks) + " BRICKS HANDED OUT!**\n\n" + "We are at **" + str(percentage) + "%** of our goal to **BUILD THE WALL** starting from Imperial Beach, CA to Brownsville, Texas! Lets make sure everyone gets a brick in the United States! For every Centipede a brick, for every brick a Centipede!\n\n" + "At this rate, the wall will be **" + str(length) + " MILES WIDE** and **" + str(height) + " FEET HIGH** by tomorrow! **DO YOUR PART!**"
  45. comment.reply(reply_string)#post it!
  46. print("POSTED!") #notify console!
  47. posts_replied_to.append(comment.fullname)
  48. #save stats to file
  49. with open('WallStats.txt', 'r+') as outFile:
  50. outFile.write(str(numBricks) + "\n" + str(percentage) + "\n" + str(length) + "\n" + str(height))
  51. with open("posts_replied_to.txt", "w") as f:
  52. for post_id in posts_replied_to:
  53. f.write(post_id + "\n")
  54.  
  55. elif(re.search("quadruple brick", comment.body, re.IGNORECASE) or re.search("quad brick", comment.body, re.IGNORECASE) or re.search("four brick", comment.body, re.IGNORECASE) or re.search("four more brick", comment.body, re.IGNORECASE) or re.search("4 more brick", comment.body, re.IGNORECASE) or re.search("4 brick", comment.body, re.IGNORECASE)) and not comment.author==reddit.user.me() and comment.fullname not in posts_replied_to:
  56. #increase stats!
  57. numBricks += 4
  58. percentage += random.uniform(0,0.001)
  59. length += random.uniform(0,0.09)
  60. height += random.uniform(0,0.004)
  61.  
  62. print("Readying QUADRUPLE shitpost " + str(numBricks) + "!") #message to console
  63. #build the comment!
  64. reply_string = "#[QUAD DAMAGE!](https://www.youtube.com/watch?v=uG6oBC0Ym5c)\n\n#**FOUR BRICKS! FOOOOOOOOUUUUUUR! LADIES AND GENTLEMEN, THIS CENTIPEDE IS ABOUT TO DOMINATE!!!**\n\n**THAT'S " + str(numBricks) + " BRICKS HANDED OUT!**\n\n" + "We are at **" + str(percentage) + "%** of our goal to **BUILD THE WALL** starting from Imperial Beach, CA to Brownsville, Texas! Lets make sure everyone gets a brick in the United States! For every Centipede a brick, for every brick a Centipede!\n\n" + "At this rate, the wall will be **" + str(length) + " MILES WIDE** and **" + str(height) + " FEET HIGH** by tomorrow! **DO YOUR PART!**"
  65. comment.reply(reply_string)#post it!
  66. print("POSTED!") #notify console!
  67. posts_replied_to.append(comment.fullname)
  68. #save stats to file
  69. with open('WallStats.txt', 'r+') as outFile:
  70. outFile.write(str(numBricks) + "\n" + str(percentage) + "\n" + str(length) + "\n" + str(height))
  71. with open("posts_replied_to.txt", "w") as f:
  72. for post_id in posts_replied_to:
  73. f.write(post_id + "\n")
  74.  
  75.  
  76. #... and so on.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement