for comment in r.subreddit('test').comments(limit = 500):
if "https://www.youtube.com/watch?v=dQw4w9WgXcQ" in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me():
print ("Rick Roll Found!") and comment.id
comment.reply("Dont be fooled this link is a rick roll! Bleep Bleep Bloop Bloop I am a bot!")
print("replied to comment") and comment.id
comments_replied_to.append(comment.id)
with open ("comments_replied_to.txt", "a"):
f.write(comment.id + "\n")
print ("going to go sleep for 30 minutes")
#sleep for 30 minutes
time.sleep(1800)
def get_saved_comments():
if not os.path.isfile("comments_replied_to.txt"):
comments_replied_to = []
else:
with open("comments_replied_to.txt", "r") as f:
comments_replied_to = f.read()
comments_replied_to = comments_replied_to.split("\n")
comments_replied_to = filter(None, comments_replied_to)
return comments_replied_to
r = bot_login()
comments_replied_to = get_saved_comments()
print (comments_replied_to)
while True:
run_bot(r, comments_replied_to)