From 40b872e3cd8ae856dcb19f0be953a81cbf293806 Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Sun, 21 Feb 2021 14:24:45 +0900 Subject: [PATCH] Implement avg speed and 2 hr EPrate --- miyu_bot/commands/cogs/event.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/miyu_bot/commands/cogs/event.py b/miyu_bot/commands/cogs/event.py index 421bdea..d622d53 100644 --- a/miyu_bot/commands/cogs/event.py +++ b/miyu_bot/commands/cogs/event.py @@ -3,6 +3,7 @@ import datetime import datetime as dt import logging +import math import aiohttp import dateutil.parser import discord @@ -30,6 +31,7 @@ class Event(commands.Cog): def __init__(self, bot): self.bot = bot self.logger = logging.getLogger(__name__) + self.EPRATE_RESOLUTION = 2 #Resolution of the Rate/hr reported by endpoint in hours. @commands.command(name='event', aliases=['ev'], @@ -301,8 +303,13 @@ class Event(commands.Cog): embed = discord.Embed(title=f'{event.name} [t{tier}]', timestamp=dt.datetime.now(dt.timezone.utc)) embed.set_thumbnail(url=self.bot.asset_url + get_event_logo_path(event)) + + + + average_rate="\n( +"+str(math.ceil((data['rate']*self.EPRATE_RESOLUTION)/data['count']))+" avg )" if int(tier)<=20 else "" #Only T20 is tracked in real-time, we can't guarantee <2hr intervals for other points so the rate returned is just overall rate. + embed.add_field(name='Points', - value=data['points'], + value=str(data['points'])+average_rate, inline=True) embed.add_field(name='Last Update', value=data['lastUpdate'],