Log truth counting

This commit is contained in:
Nexus 2024-04-15 19:50:17 +01:00
parent 2fb9fc77a2
commit 52e25c5de1
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -1,4 +1,5 @@
import asyncio
import logging
import re
import discord
@ -17,6 +18,7 @@ class QuoteQuota(commands.Cog):
self.bot = bot
self.quotes_channel_id = CONFIG["quote_a"].get("channel_id")
self.names = CONFIG["quote_a"].get("names", {})
self.log = logging.getLogger("jimmy.cogs.quote_quota")
@property
def quotes_channel(self) -> discord.TextChannel | None:
@ -202,6 +204,8 @@ class QuoteQuota(commands.Cog):
}
for message in messages:
if filter_func(message):
age = now - message.created_at
self.log.info("%r was a truth (%.2f seconds ago).", message, age.total_seconds())
counts["all_time"] += 1
if message.created_at > now - timedelta(hours=1):
counts["hour"] += 1
@ -213,6 +217,7 @@ class QuoteQuota(commands.Cog):
counts["per_minute"] = counts["hour"] / 60
counts["per_hour"] = counts["day"] / 24
counts["per_day"] = counts["week"] / 7
self.log.info("Total truth counts: %r", counts)
return counts
async def _process_trump_truths(self, messages: list[discord.Message]) -> dict[str, int]: