Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. import praw
  2. from time import sleep
  3. import random
  4.  
  5.  
  6. user = "bootcut_bandit"
  7. pword = "moneys"
  8. clientid = "KPSi-reky-ONLA"
  9. clientsecret = "R8NWp3gpeA17cP51U0EOUGIf3u0"
  10. subreddit_monitor = "sneakers"
  11.  
  12.  
  13. def bot_login():
  14. logit = praw.Reddit(username = user,
  15. password = pword,
  16. client_id = clientid,
  17. client_secret = clientsecret,
  18. user_agent = "bot test v0.1")
  19. return logit
  20.  
  21.  
  22. def run_bot(r,sm):
  23. mlist=[]
  24. qi = random.randrange(1,5)
  25. quotes = {1:"#*The bootcut bandit strikes again!*",
  26. 2:"#*BOOOOOOTTCUUUUUUUTTT BAAAAAAAAANNDDIIIIT!!!*",
  27. 3:"#*B O O T C U T B A N D I T*",
  28. 4:"***B O O T C U T B A N D I T***\n\n***O***\n\n***O***\n\n***T***\n\n***C***\n\n***U***\n\n***T***\n\n***B***\n\n***A***\n\n***N***\n\n***D***\n\n***I***\n\n***T***"}
  29. for i in r.subreddit(sm).comments(limit=500):
  30. with open("already_replied.txt","r") as z:
  31. mlist=z.read().splitlines()
  32. if "!BOOTCUTBANDIT" in i.body.upper() and i.id not in mlist:
  33. i.reply(quotes[qi]) # this is the reply
  34. with open("already_replied.txt","a") as f:
  35. f.write(i.id + "\n")
  36. # mlist.append(i.id)
  37. print("found string")
  38. #else:
  39. #print("string not found")
  40. print("sleeping")
  41. sleep(15)
  42.  
  43. def send_msg(r, username, subject, body):
  44. r.redditor(username).message(subject, body)
  45.  
  46.  
  47. def main():
  48. r = bot_login()
  49. while True:
  50. run_bot(r, subreddit_monitor)
  51.  
  52.  
  53. main()
  54.  
  55. # this will send message to someone in PM
  56. # r=bot_login()
  57. # send_msg(r, "pissymon","test", "***B O O T C U T B A N D I T***\n\n***O***\n\n***O***\n\n***T***\n\n***C***\n\n***U***\n\n***T***\n\n***B***\n\n***A***\n\n***N***\n\n***D***\n\n***I***\n\n***T***")
  58.  
  59.  
  60.  
  61. # this will show the newest posts in the test subreddit sorted by hot
  62. # for i in r.subreddit('test').hot(limit=10):
  63. # print(i.title)
  64.  
  65. #for i in r.subreddit('sneakers').hot(limit=10):
  66. # print(i.title)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement