General cleanup

- Moved alert removal reminder to bottom of message

- debug output of alerts to discord only on debug environments
This commit is contained in:
Emily Doherty 2024-12-20 18:58:42 -08:00
parent f20a8c6476
commit 2164e98730

View File

@ -2,6 +2,7 @@ import asyncio
import copy import copy
import datetime import datetime
import logging import logging
import os
from typing import Type, Dict, List from typing import Type, Dict, List
import aiohttp import aiohttp
@ -88,9 +89,7 @@ class Tracker(Extension):
title="GoblinBot Tracker Alert Triggered", title="GoblinBot Tracker Alert Triggered",
color=0xB10000, color=0xB10000,
description=f"Hello, you requested to be sent an alert when the price of the World of Warcraft " description=f"Hello, you requested to be sent an alert when the price of the World of Warcraft "
f"token reaches a certain value.\n\n" f"token reaches a certain value.\n\n",
f"As a reminder, you can remove an alert via ```/remove-alert```\n"
f"or you can remove all alerts and user data via ```/remove-registration```\n\n",
) )
] ]
alerts_by_flavor = await gather_alerts_by_flavor(users_alerts[user]) alerts_by_flavor = await gather_alerts_by_flavor(users_alerts[user])
@ -100,7 +99,14 @@ class Tracker(Extension):
alerts_by_flavor[flavor], user=user alerts_by_flavor[flavor], user=user
) )
) )
embeds.append(
Embed(
title="",
color=0xB10000,
description=f"As a reminder, you can remove an alert via ```/remove-alert```\n"
f"or you can remove all alerts and user data via ```/remove-registration```\n",
)
)
await discord_user.send(embeds=embeds) await discord_user.send(embeds=embeds)
self.bot.logger.log( self.bot.logger.log(
logging.INFO, "TokenBot Tracker: Done Processing User Alerts" logging.INFO, "TokenBot Tracker: Done Processing User Alerts"
@ -497,9 +503,9 @@ class Tracker(Extension):
f"Last Alerting Time: <t:{int(trigger.last_alerting[0].timestamp())}:F> local time\n" f"Last Alerting Time: <t:{int(trigger.last_alerting[0].timestamp())}:F> local time\n"
f"[Link to this Chart]({self._render_token_url(alert)})\n" f"[Link to this Chart]({self._render_token_url(alert)})\n"
) )
if user is not None and user.user_id == 265678699435655169: if os.getenv("ENV") == "DEBUG":
alert_str += ( alert_str += (
f"\nShowing you some internals since you are the bot owner:\n" f"\nShowing you some internals since this is a DEBUG build:\n"
f"```history.last_price_datum:\n" f"```history.last_price_datum:\n"
f"\t{history.last_price_datum[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n" f"\t{history.last_price_datum[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n"
f"\t{history.last_price_datum[1]}\n" f"\t{history.last_price_datum[1]}\n"