Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import random
- import time
- import os
- import re
- # reddit api login and authentication
- reddit = praw.Reddit(client_id='',
- client_secret='',
- username='',
- password='',
- user_agent='Comment Bot by Skwiid')
- print("Welcome to Skwiid's Comment Bot " + str(reddit.user.me()))
- #Variables
- keyword = ["[F4M]", "[M4F]" , "[f4m]" , "[m4f]", "[F4A]", "[M4A]", "[m4a]", "[f4a]"]
- reply = "I'm soo fucking horny daddy, add me on snapchat: AlanaxMae"
- #What Subbreddit to comment on!
- subreddit = reddit.subreddit('DirtySnapchat')
- #Comment Function w/ infinite loop
- def comment(submissions_replied_to):
- global keyword
- global reply
- global subreddit
- while True:
- try:
- for submission in subreddit.stream.submissions():
- for word in keyword:
- if word in submission.title and submission.id not in submissions_replied_to:
- print("Posting..")
- submission.reply(reply)
- submissions_replied_to.append(submission.id)
- with open ("submissions_replied_to.txt", "a") as f:
- f.write(submission.id + "\n")
- except praw.exceptions.APIException as e:
- print(e)
- if (e.error_type == "RATELIMIT"):
- delay = re.search("(\d+) minutes", e.message)
- if delay:
- delay_seconds = float(int(delay.group(1)) * 60)
- print("Sleeping for " + str(delay_seconds) + " seconds..")
- time.sleep(delay_seconds)
- print("Sleep Over, Posting..")
- comment()
- else:
- delay = re.search("(\d+) seconds", e.message)
- delay_seconds = float(delay.group(1))
- print("Sleeping for " + str(delay_seconds) + " seconds..")
- time.sleep(delay_seconds)
- print("Sleep Over, Posting..")
- comment()
- #Saved Submissions
- def get_saved_submissions():
- if not os.path.isfile("submissions_replied_to.txt"):
- submissions_replied_to = []
- else:
- with open("submissions_replied_to.txt", "r") as f:
- submissions_replied_to = f.read()
- submissions_replied_to = submissions_replied_to.split("\n")
- return submissions_replied_to
- submissions_replied_to = get_saved_submissions()
- print(submissions_replied_to)
- #Execute Comment Function
- #comment(submissions_replied_to)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement