From c95cbcdc69d97cc7766327dc21a6bf0ef3cb2980 Mon Sep 17 00:00:00 2001 From: omame Date: Sun, 1 Jan 2023 13:38:04 +0100 Subject: [PATCH] feat(analytics): track sent messages chore: bump version --- bob/__init__.py | 2 +- cogs/config.py | 6 +++++- cogs/lar.py | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bob/__init__.py b/bob/__init__.py index 7593a04..dd5b094 100644 --- a/bob/__init__.py +++ b/bob/__init__.py @@ -1,7 +1,7 @@ """ Constants used by bob. """ -__version__ = "2.8.0" +__version__ = "2.8.1" import random diff --git a/cogs/config.py b/cogs/config.py index 96d6d92..efe7a47 100644 --- a/cogs/config.py +++ b/cogs/config.py @@ -24,6 +24,7 @@ def __init__(self, client: commands.Bot): "blacklist": [], "analytics": [], } + self.messages_sent = 0 self.question_map = {} if os.path.exists("topgg.txt"): with open("topgg.txt") as file: @@ -132,7 +133,10 @@ async def log_data(self): responses = len([response for question in self.question_map.values() for response in question.responses]) self.logger.debug("adding analytics info...") - self.config["analytics"].append([len(self.question_map), responses, len(self.client.guilds), time.time()]) + self.config["analytics"].append([len(self.question_map), responses, len(self.client.guilds), time.time(), + self.messages_sent]) + + self.messages_sent = 0 if len(self.config["analytics"]) > 30: self.config["analytics"] = self.config["analytics"][-30:] diff --git a/cogs/lar.py b/cogs/lar.py index 781128b..7bee891 100644 --- a/cogs/lar.py +++ b/cogs/lar.py @@ -75,6 +75,7 @@ async def reply(self, message: discord.Message): if self.mod_mode.is_in_mod_mode(guild, message.author): self.mod_mode.save_info(guild, message.author, message_reply, question, response) self.logger.debug(f"reply: {message.clean_content} -> {text}") + self.config.messages_sent += 1 @commands.Cog.listener() async def on_message(self, message: discord.Message):