config options distinguish_comment, lock_post, and distinguish_sticky added

This commit is contained in:
2026-02-22 22:21:11 +00:00
parent 6fbb2a6196
commit 90669cc634
2 changed files with 18 additions and 2 deletions

View File

@@ -19,3 +19,11 @@ comment_message = "Hello OP! It has been at least __2 days__ since you last repl
# Whether the bot should distinguish the posted comment (True/False)
distinguish_comment = True
# Whether the bot should lock the post after posting the comment (True/False)
# Default is False to avoid accidental locking; set to True to enable locking.
lock_post = False
# Whether the distinguished comment should be stickied (True/False)
# Some subreddits may require `True` to keep moderator comments visible.
distinguish_sticky = False

View File

@@ -29,10 +29,18 @@ def main(reddit, posts: dict):
if time.time() > posts[submission] + (config.hours * 60 * 60):
posts.pop(submission)
reddit.submission(submission).save()
comment = reddit.submission(submission).reply(body=config.comment_message)
# Optionally lock the post if configured
if getattr(config, 'lock_post', False):
try:
reddit.submission(submission).mod.lock()
except Exception as e:
print(f"Could not lock submission: {e}")
comment = reddit.submission(submission).reply(body=config.comment_message).mod.distinguish(sticky=True)
if getattr(config, 'distinguish_comment', False):
try:
comment.mod.distinguish(how="yes")
sticky = getattr(config, 'distinguish_sticky', False)
comment.mod.distinguish(how="yes", sticky=sticky)
except Exception as e:
print(f"Could not distinguish comment: {e}")
print(f"Post {submission} has been flaired {config.flair_text} for {config.hours} hours, posted comment")