Guest User

NocoinBot

a guest
Aug 7th, 2018
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. import praw
  2. import config
  3. import time
  4. import os
  5. import random
  6.  
  7.  
  8. answers = random.sample([
  9. "Thanks for the support dude, really appreciate it!" + "\n\n ^\(I ^am ^a ^bot.) ^[*Website*](http://www.NocoinProject.org) ^/ ^[*Reddit*](https://reddit.com/r/NocoinProject)",
  10. "Free Nocoin giveaway!" + "\n\n Send 1M Nocoin and I will send you nothing back." + "\n\n ^\(I ^am ^a ^bot.) ^[*Website*](http://www.NocoinProject.org) ^/ ^[*Reddit*](https://reddit.com/r/NocoinProject)",
  11. "Hey, I heard you mentioned Nocoin? That is awesome thank you for the support! You have been awarded 1M Nocoin, don't forget to claim them on our website." + "\n\n ^\(I ^am ^a ^bot.) ^[*Website*](http://www.NocoinProject.org) ^/ ^[*Reddit*](https://reddit.com/r/NocoinProject)",
  12. "Wow, another person shilling Nocoin. Now we're two." + "\n\n ^\(I ^am ^a ^bot.) ^[*Website*](http://www.NocoinProject.org) ^/ ^[*Reddit*](https://reddit.com/r/NocoinProject)"], 1)
  13.  
  14. def bot_login():
  15. print ("Logging in...")
  16. r = praw.Reddit(username = config.username,
  17. password = config.password,
  18. client_id = config.client_id,
  19. client_secret = config.client_secret,
  20. user_agent = "NocoinShillBot")
  21. print ("Logged in!")
  22.  
  23. return r
  24.  
  25. def run_bot(r, comments_replied_to):
  26. print ("Searching last 1,000 comments")
  27.  
  28. for comment in r.subreddit('Buttcoin').comments(limit=1000):
  29. if "Nocoiner" or "nocoiner" or "No coiner" or "no coiner" or "Nocoin" or "NoCoin" in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me():
  30. print ("String with \"Nocoiner\" found in comment " + comment.id)
  31. comment.reply(answers)
  32. print ("Replied to comment " + comment.id)
  33.  
  34. comments_replied_to = [];
  35. comments_replied_to.append(comment.id)
  36.  
  37. with open ("comments_replied_to.txt", "a") as f:
  38. f.write(comment.id + "\n")
  39.  
  40. print ("Search Completed.")
  41.  
  42. print (comments_replied_to)
  43.  
  44. print ("Sleeping for 10 seconds...")
  45.  
  46. time.sleep(10)
  47.  
  48. def get_saved_comments():
  49. if not os.path.isfile("comments_replied_to.txt"):
  50. comments_replied_to = []
  51. else:
  52. with open("comments_replied_to.txt", "r") as f:
  53. comments_replied_to = f.read()
  54. comments_replied_to = comments_replied_to.split("\n")
  55. comments_replied_to = filter(None, comments_replied_to)
  56.  
  57. return comments_replied_to
  58.  
  59. r = bot_login()
  60. comments_replied_to = get_saved_comments()
  61. print (comments_replied_to)
  62.  
  63. while True:
  64. run_bot(r, comments_replied_to)
Add Comment
Please, Sign In to add comment