diff --git a/config.defaults.json b/config.defaults.json index 8559aa0..8216794 100644 --- a/config.defaults.json +++ b/config.defaults.json @@ -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, diff --git a/reply.py b/reply.py index 226efcd..201d356 100755 --- a/reply.py +++ b/reply.py @@ -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']: