From 90669cc634bf7abc921e1b0f755470553ec71a31 Mon Sep 17 00:00:00 2001 From: Slfhstd Date: Sun, 22 Feb 2026 22:21:11 +0000 Subject: [PATCH] config options distinguish_comment, lock_post, and distinguish_sticky added --- config/config.py | 8 ++++++++ flairtimercomment.py | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/config/config.py b/config/config.py index ebd20a0..d800d67 100644 --- a/config/config.py +++ b/config/config.py @@ -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 diff --git a/flairtimercomment.py b/flairtimercomment.py index 1f9483a..8d706bd 100644 --- a/flairtimercomment.py +++ b/flairtimercomment.py @@ -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")