I use a large number of scripts to act when some stuff happen on my subreddits.
Until last week, it used to work good, without any problem whatsoever, for example one of them is to congratulate users when they reach a certain amount of upvotes (by commenting an event we host). Here’s my code :
for submission in reddit.subreddit(sub).new(limit=None):
idCheckerCom = open("idCheckerCom", "r")
idCheckerMod = open("idCheckerMod", "r")
if str(submission.id) not in idCheckerCom.read():
if submission.score >= int(float(amount)):
if str(submission.created_utc) > start:
with open("idCheckerCom", "a") as f:
f.write(str(submission.id) + "\n")
do_something()
However now when the repl restarts it will completely ignore ligne 4 (if str(submission.id) not in idCheckerCom.read():)
(or it will not read the document properly, I don’t know) and it will message the user once again every time the script restarts. I should add that manual restarts do not reproduce this error, only when the repl goes to sleep and is back up with always on.
Last night it spammed various users 12 times. This is unacceptable.
What is causing this and how can I prevent it ?