mirror of
https://git.kiwifarms.net/mint/ebooks.git
synced 2024-10-22 23:29:06 +00:00
Hellthread threshold
This commit is contained in:
parent
b064d72733
commit
3ca7aceacb
2 changed files with 13 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
"ignored_cws": [],
|
"ignored_cws": [],
|
||||||
"mention_handling": 1,
|
"mention_handling": 1,
|
||||||
"max_thread_length": 15,
|
"max_thread_length": 15,
|
||||||
|
"hellthread_threshold": 5,
|
||||||
"strip_paired_punctuation": false,
|
"strip_paired_punctuation": false,
|
||||||
"limit_length": false,
|
"limit_length": false,
|
||||||
"length_lower_limit": 5,
|
"length_lower_limit": 5,
|
||||||
|
|
13
reply.py
13
reply.py
|
@ -27,6 +27,10 @@ class ReplyBot:
|
||||||
post_id = notification['status']['id']
|
post_id = notification['status']['id']
|
||||||
context = await self.pleroma.status_context(post_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
|
# check if we've already been participating in this thread
|
||||||
if self.check_thread_length(context):
|
if self.check_thread_length(context):
|
||||||
return
|
return
|
||||||
|
@ -40,7 +44,14 @@ class ReplyBot:
|
||||||
else:
|
else:
|
||||||
await self.reply(notification)
|
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"""
|
"""return whether the thread is too long to reply to"""
|
||||||
posts = 0
|
posts = 0
|
||||||
for post in context['ancestors']:
|
for post in context['ancestors']:
|
||||||
|
|
Loading…
Reference in a new issue