Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. import praw
  2. import random
  3. import time
  4. import os
  5. import re
  6.  
  7. # reddit api login and authentication
  8. reddit = praw.Reddit(client_id='',
  9. client_secret='',
  10. username='',
  11. password='',
  12. user_agent='Comment Bot by Skwiid')
  13. print("Welcome to Skwiid's Comment Bot " + str(reddit.user.me()))
  14.  
  15.  
  16. #Variables
  17. keyword = ["[F4M]", "[M4F]" , "[f4m]" , "[m4f]", "[F4A]", "[M4A]", "[m4a]", "[f4a]"]
  18. reply = "I'm soo fucking horny daddy, add me on snapchat: AlanaxMae"
  19.  
  20.  
  21.  
  22. #What Subbreddit to comment on!
  23. subreddit = reddit.subreddit('DirtySnapchat')
  24.  
  25.  
  26. #Comment Function w/ infinite loop
  27. def comment(submissions_replied_to):
  28. global keyword
  29. global reply
  30. global subreddit
  31.  
  32. while True:
  33. try:
  34. for submission in subreddit.stream.submissions():
  35. for word in keyword:
  36. if word in submission.title and submission.id not in submissions_replied_to:
  37. print("Posting..")
  38. submission.reply(reply)
  39. submissions_replied_to.append(submission.id)
  40.  
  41.  
  42.  
  43. with open ("submissions_replied_to.txt", "a") as f:
  44. f.write(submission.id + "\n")
  45.  
  46. except praw.exceptions.APIException as e:
  47. print(e)
  48. if (e.error_type == "RATELIMIT"):
  49. delay = re.search("(\d+) minutes", e.message)
  50.  
  51. if delay:
  52. delay_seconds = float(int(delay.group(1)) * 60)
  53. print("Sleeping for " + str(delay_seconds) + " seconds..")
  54. time.sleep(delay_seconds)
  55. print("Sleep Over, Posting..")
  56. comment()
  57. else:
  58. delay = re.search("(\d+) seconds", e.message)
  59. delay_seconds = float(delay.group(1))
  60. print("Sleeping for " + str(delay_seconds) + " seconds..")
  61. time.sleep(delay_seconds)
  62. print("Sleep Over, Posting..")
  63. comment()
  64.  
  65. #Saved Submissions
  66. def get_saved_submissions():
  67. if not os.path.isfile("submissions_replied_to.txt"):
  68. submissions_replied_to = []
  69. else:
  70. with open("submissions_replied_to.txt", "r") as f:
  71. submissions_replied_to = f.read()
  72. submissions_replied_to = submissions_replied_to.split("\n")
  73.  
  74. return submissions_replied_to
  75.  
  76.  
  77.  
  78.  
  79. submissions_replied_to = get_saved_submissions()
  80. print(submissions_replied_to)
  81.  
  82.  
  83. #Execute Comment Function
  84. #comment(submissions_replied_to)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement