config options distinguish_comment, lock_post, and distinguish_sticky added
This commit is contained in:
@@ -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)
|
# Whether the bot should distinguish the posted comment (True/False)
|
||||||
distinguish_comment = True
|
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
|
||||||
|
|||||||
@@ -29,10 +29,18 @@ def main(reddit, posts: dict):
|
|||||||
if time.time() > posts[submission] + (config.hours * 60 * 60):
|
if time.time() > posts[submission] + (config.hours * 60 * 60):
|
||||||
posts.pop(submission)
|
posts.pop(submission)
|
||||||
reddit.submission(submission).save()
|
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):
|
if getattr(config, 'distinguish_comment', False):
|
||||||
try:
|
try:
|
||||||
comment.mod.distinguish(how="yes")
|
sticky = getattr(config, 'distinguish_sticky', False)
|
||||||
|
comment.mod.distinguish(how="yes", sticky=sticky)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Could not distinguish comment: {e}")
|
print(f"Could not distinguish comment: {e}")
|
||||||
print(f"Post {submission} has been flaired {config.flair_text} for {config.hours} hours, posted comment")
|
print(f"Post {submission} has been flaired {config.flair_text} for {config.hours} hours, posted comment")
|
||||||
|
|||||||
Reference in New Issue
Block a user