Include a link to the chart in a given alert render

This commit is contained in:
Emily Doherty 2024-12-08 18:13:03 -08:00
parent cd23c8e350
commit dd97d9b1f9

View File

@ -456,6 +456,7 @@ class Tracker(Extension):
alert_str = (
f"Last Alerting Price Value: {format(trigger.last_alerting[1], ",")}\n"
f"Last Alerting Time: {trigger.last_alerting[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n"
f"[Link to this Chart]({self._render_token_url(alert)})"
)
if user is not None and user.user_id == 265678699435655169:
alert_str += (
@ -486,3 +487,24 @@ class Tracker(Extension):
fields=fields,
)
return embed
def _render_token_url(self, alert: Alert) -> str:
match alert.flavor:
case Flavor.CLASSIC:
url = "https://classic.wowtoken.app/?"
case Flavor.RETAIL:
url = "https://wowtoken.app/?"
case _:
raise NotImplementedError
url += f"region={alert.region.value}&"
match alert.alert_type:
case AlertType.WEEKLY_LOW | AlertType.WEEKLY_HIGH:
url += "time=168h&"
case AlertType.MONTHLY_LOW | AlertType.MONTHLY_HIGH:
url += "time=720h&"
case AlertType.YEARLY_LOW | AlertType.YEARLY_HIGH:
url += "time=1y&"
case AlertType.ALL_TIME_LOW | AlertType.ALL_TIME_HIGH:
url += "time=all&"
return url