Add "today" truth counter
This commit is contained in:
parent
cbd3b47aed
commit
aa017fca6c
1 changed files with 10 additions and 2 deletions
|
@ -174,10 +174,14 @@ class QuoteQuota(commands.Cog):
|
||||||
def _metacounter(
|
def _metacounter(
|
||||||
self, messages: list[discord.Message], filter_func: Callable[[discord.Message], bool], *, now: datetime = None
|
self, messages: list[discord.Message], filter_func: Callable[[discord.Message], bool], *, now: datetime = None
|
||||||
) -> dict[str, float | int]:
|
) -> dict[str, float | int]:
|
||||||
|
def _is_today(date: datetime) -> bool:
|
||||||
|
return date.date() == now.date()
|
||||||
|
|
||||||
now = now or discord.utils.utcnow().replace(minute=0, second=0, microsecond=0)
|
now = now or discord.utils.utcnow().replace(minute=0, second=0, microsecond=0)
|
||||||
counts = {
|
counts = {
|
||||||
"hour": 0,
|
"hour": 0,
|
||||||
"day": 0,
|
"day": 0,
|
||||||
|
"today": 0,
|
||||||
"week": 0,
|
"week": 0,
|
||||||
"all_time": 0,
|
"all_time": 0,
|
||||||
"per_minute": 0.0,
|
"per_minute": 0.0,
|
||||||
|
@ -189,6 +193,8 @@ class QuoteQuota(commands.Cog):
|
||||||
age = now - message.created_at
|
age = now - message.created_at
|
||||||
self.log.debug("%r was a truth (%.2f seconds ago).", message.id, age.total_seconds())
|
self.log.debug("%r was a truth (%.2f seconds ago).", message.id, age.total_seconds())
|
||||||
counts["all_time"] += 1
|
counts["all_time"] += 1
|
||||||
|
if _is_today(message.created_at):
|
||||||
|
counts["today"] += 1
|
||||||
if message.created_at > now - timedelta(hours=1):
|
if message.created_at > now - timedelta(hours=1):
|
||||||
counts["hour"] += 1
|
counts["hour"] += 1
|
||||||
if message.created_at > now - timedelta(days=1):
|
if message.created_at > now - timedelta(days=1):
|
||||||
|
@ -264,7 +270,8 @@ class QuoteQuota(commands.Cog):
|
||||||
value=(
|
value=(
|
||||||
f"**All time:** {trump_stats['all_time']:,}\n"
|
f"**All time:** {trump_stats['all_time']:,}\n"
|
||||||
f"**Last Week:** {trump_stats['week']:,} ({trump_stats['per_day']:.1f}/day)\n"
|
f"**Last Week:** {trump_stats['week']:,} ({trump_stats['per_day']:.1f}/day)\n"
|
||||||
f"**Last Day:** {trump_stats['day']:,} ({trump_stats['per_hour']:.1f}/hour)\n"
|
f"**Today:** {trump_stats['today']:,}\n"
|
||||||
|
f"**Last 24 Hours:** {trump_stats['day']:,} ({trump_stats['per_hour']:.1f}/hour)\n"
|
||||||
f"**Last Hour:** {trump_stats['hour']:,} ({trump_stats['per_minute']:.1f}/min)"
|
f"**Last Hour:** {trump_stats['hour']:,} ({trump_stats['per_minute']:.1f}/min)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -273,7 +280,8 @@ class QuoteQuota(commands.Cog):
|
||||||
value=(
|
value=(
|
||||||
f"**All time:** {tate_stats['all_time']:,}\n"
|
f"**All time:** {tate_stats['all_time']:,}\n"
|
||||||
f"**Last Week:** {tate_stats['week']:,} ({tate_stats['per_day']:.1f}/day)\n"
|
f"**Last Week:** {tate_stats['week']:,} ({tate_stats['per_day']:.1f}/day)\n"
|
||||||
f"**Last Day:** {tate_stats['day']:,} ({tate_stats['per_hour']:.1f}/hour)\n"
|
f"**Today:** {tate_stats['today']:,}\n"
|
||||||
|
f"**Last 24 Hours:** {tate_stats['day']:,} ({tate_stats['per_hour']:.1f}/hour)\n"
|
||||||
f"**Last Hour:** {tate_stats['hour']:,} ({tate_stats['per_minute']:.1f}/min)"
|
f"**Last Hour:** {tate_stats['hour']:,} ({tate_stats['per_minute']:.1f}/min)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue