Advertisement
Guest User

Untitled

a guest
Jan 5th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. import praw
  2. import time
  3. import os
  4. import datetime
  5.  
  6. def bot_login():
  7. r = praw.Reddit(username = "Ridiculous_Bot",
  8. password = "",
  9. client_id = "",
  10. client_secret = "",
  11. user_agent = "Ridiculous Responder")
  12.  
  13. return r
  14.  
  15. def run_bot(r, comments_replied_to):
  16. for comment in r.subreddit('funny+politicalhumor+gaming+videos+quityourbullshit+dankmemes+meirl+me_irl+2meirl4meirl').comments(limit=1):
  17. if "ridiculous" in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me():
  18. comments_replied_to.append(comment.id)
  19. print ("found a ridiculous at " + st)
  20. comment.reply("[Ridiculous](https://www.youtube.com/watch?v=NeMIadSI4As)")
  21.  
  22. with open ("comments_replied_to.txt", "a") as f:
  23. f.write(comment.id + "\n")
  24.  
  25.  
  26. def get_saved_comments():
  27. if not os.path.isfile("comments_replied_to.txt"):
  28. comments_replied_to = []
  29. else:
  30. with open("comments_replied_to.txt", "r") as f:
  31. comments_replied_to = f.read()
  32. comments_replied_to = comments_replied_to.split("\n")
  33. return comments_replied_to
  34.  
  35. st = datetime.datetime.now().strftime("%A, %B %d. %I:%M%p %Y")
  36. r = bot_login()
  37. comments_replied_to = get_saved_comments()
  38. print (comments_replied_to)
  39. while True:
  40. run_bot(r, comments_replied_to)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement