From 5e2ebc628a2f6aa5fd8e70fdf70e7b1ef6b875cc Mon Sep 17 00:00:00 2001 From: spla Date: Wed, 28 Jun 2023 20:27:11 +0200 Subject: [PATCH] Added Active Half Year data --- mastobot.py | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/mastobot.py b/mastobot.py index 0eca58d..64bd719 100644 --- a/mastobot.py +++ b/mastobot.py @@ -83,6 +83,10 @@ class Mastobot: mau = '{:,}'.format(mau).replace(',','.') + ahy = self.mastodon.instance_nodeinfo().usage.users.activeHalfyear + + ahy = '{:,}'.format(ahy).replace(',','.') + registers = self.mastodon.instance().stats.user_count registers = '{:,}'.format(registers).replace(',','.') @@ -113,7 +117,9 @@ class Mastobot: post_text += f"Usuaris actius (mes): {mau}\n" - post_text += f"Apunts: {posts}\n" + post_text += f"Usuaris actius (6 mesos): {ahy}\n" + + post_text += f"Tuts: {posts}\n" post_text += f"Servidors federats: {peers}\n\n" @@ -144,6 +150,8 @@ class Mastobot: reply = False + question = '' + keyword = '' content = self.cleanhtml(self, text) @@ -153,20 +161,29 @@ class Mastobot: try: start = content.index("@") - end = content.index(" ") - if len(content) > end: - content = content[0: start:] + content[end +1::] + if " " in content: - cleanit = content.count('@') + end = content.index(" ") - i = 0 - while i < cleanit : + if len(content) > end: + + content = content[0: start:] + content[end +1::] + + cleanit = content.count('@') + + i = 0 + + while i < cleanit : + + start = content.rfind("@") + end = len(content) + content = content[0: start:] + content[end +1::] + i += 1 + else: + + return reply, question - start = content.rfind("@") - end = len(content) - content = content[0: start:] + content[end +1::] - i += 1 content = content.lower() question = content