Compare commits

...

2 Commits

Author SHA1 Message Date
7c6b66660e Bump version 2024-12-14 20:43:22 -08:00
dfa5637a42 Log when alerts are being sent for restart safety
Maybe we could catch and hold signals here too?
2024-12-14 20:43:12 -08:00
2 changed files with 23 additions and 19 deletions

View File

@ -8,7 +8,7 @@ from interactions.api.events import Startup
from token_bot.token_database import database as pdb from token_bot.token_database import database as pdb
from token_bot.token_database import database as tdb from token_bot.token_database import database as tdb
VERSION = "0.9.1" VERSION = "0.9.2"
class Core(Extension): class Core(Extension):

View File

@ -77,25 +77,29 @@ class Tracker(Extension):
users_alerts[user] = [alert] users_alerts[user] = [alert]
else: else:
users_alerts[user].append(alert) users_alerts[user].append(alert)
for user in users_alerts: if users_alerts:
discord_user = await self.bot.fetch_user(user.user_id) self.bot.logger.log(logging.INFO, "TokenBot Tracker: Processing User Alerts")
embeds = [ for user in users_alerts:
Embed( discord_user = await self.bot.fetch_user(user.user_id)
title="GoblinBot Tracker Alert Triggered", embeds = [
color=0xB10000, Embed(
description=f"Hello, you requested to be sent an alert when the price of the World of Warcraft " title="GoblinBot Tracker Alert Triggered",
f"token reaches a certain value.\n\n" color=0xB10000,
f"As a reminder, you can remove an alert via ```/remove-alert```\n" description=f"Hello, you requested to be sent an alert when the price of the World of Warcraft "
f"or you can remove all alerts and user data via ```/remove-registration```\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]) )
for flavor in alerts_by_flavor: ]
embeds.append( alerts_by_flavor = await gather_alerts_by_flavor(users_alerts[user])
await self._render_alert_flavor(alerts_by_flavor[flavor], user=user) for flavor in alerts_by_flavor:
) embeds.append(
await self._render_alert_flavor(alerts_by_flavor[flavor], user=user)
)
await discord_user.send(embeds=embeds)
self.bot.logger.log(logging.INFO, "TokenBot Tracker: Done Processing User Alerts")
await discord_user.send(embeds=embeds)
################################### ###################################
# Slash Commands # # Slash Commands #