From dd97d9b1f909d17e4d43bf2b4d1a536846073867 Mon Sep 17 00:00:00 2001 From: Emily Doherty Date: Sun, 8 Dec 2024 18:13:03 -0800 Subject: [PATCH] Include a link to the chart in a given alert render --- token_bot/tracker.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/token_bot/tracker.py b/token_bot/tracker.py index d1ef1d3..d51bc6f 100644 --- a/token_bot/tracker.py +++ b/token_bot/tracker.py @@ -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