commit dd97d9b1f909d17e4d43bf2b4d1a536846073867
parent cd23c8e3502454d0a1e5246b4b2ddb8974922b42
Author: Emily Doherty <git@emily.sh>
Date: Sun, 8 Dec 2024 18:13:03 -0800
Include a link to the chart in a given alert render
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git 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