Log truth counting
This commit is contained in:
parent
2fb9fc77a2
commit
52e25c5de1
1 changed files with 5 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
@ -17,6 +18,7 @@ class QuoteQuota(commands.Cog):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.quotes_channel_id = CONFIG["quote_a"].get("channel_id")
|
self.quotes_channel_id = CONFIG["quote_a"].get("channel_id")
|
||||||
self.names = CONFIG["quote_a"].get("names", {})
|
self.names = CONFIG["quote_a"].get("names", {})
|
||||||
|
self.log = logging.getLogger("jimmy.cogs.quote_quota")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def quotes_channel(self) -> discord.TextChannel | None:
|
def quotes_channel(self) -> discord.TextChannel | None:
|
||||||
|
@ -202,6 +204,8 @@ class QuoteQuota(commands.Cog):
|
||||||
}
|
}
|
||||||
for message in messages:
|
for message in messages:
|
||||||
if filter_func(message):
|
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
|
counts["all_time"] += 1
|
||||||
if message.created_at > now - timedelta(hours=1):
|
if message.created_at > now - timedelta(hours=1):
|
||||||
counts["hour"] += 1
|
counts["hour"] += 1
|
||||||
|
@ -213,6 +217,7 @@ class QuoteQuota(commands.Cog):
|
||||||
counts["per_minute"] = counts["hour"] / 60
|
counts["per_minute"] = counts["hour"] / 60
|
||||||
counts["per_hour"] = counts["day"] / 24
|
counts["per_hour"] = counts["day"] / 24
|
||||||
counts["per_day"] = counts["week"] / 7
|
counts["per_day"] = counts["week"] / 7
|
||||||
|
self.log.info("Total truth counts: %r", counts)
|
||||||
return counts
|
return counts
|
||||||
|
|
||||||
async def _process_trump_truths(self, messages: list[discord.Message]) -> dict[str, int]:
|
async def _process_trump_truths(self, messages: list[discord.Message]) -> dict[str, int]:
|
||||||
|
|
Loading…
Reference in a new issue