Hellthread threshold

This commit is contained in:
Mint 2022-12-23 11:36:57 +03:00
parent b064d72733
commit 3ca7aceacb
2 changed files with 13 additions and 1 deletions

View file

@ -6,6 +6,7 @@
"ignored_cws": [],
"mention_handling": 1,
"max_thread_length": 15,
"hellthread_threshold": 5,
"strip_paired_punctuation": false,
"limit_length": false,
"length_lower_limit": 5,

View file

@ -27,6 +27,10 @@ class ReplyBot:
post_id = notification['status']['id']
context = await self.pleroma.status_context(post_id)
# check if we've already been participating in this thread
if self.check_hellthread_size(notification):
return
# check if we've already been participating in this thread
if self.check_thread_length(context):
return
@ -40,7 +44,14 @@ class ReplyBot:
else:
await self.reply(notification)
def check_thread_length(self, context) -> bool:
def check_hellthread_size(self, notification) -> bool:
"""return whether the notification should not be replied to due to sheer amount of mentions"""
if len(notification['status']['mentions']) >= self.cfg['hellthread_threshold']:
return True
return False
def check_thread_length(self, xontext) -> bool:
"""return whether the thread is too long to reply to"""
posts = 0
for post in context['ancestors']: