Compare commits
2 Commits
fa382f4c6b
...
ed65cd836f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed65cd836f | ||
|
|
d6e9373321 |
@@ -513,6 +513,10 @@ class CrossFitBooker:
|
|||||||
logging.info(f"Successfully booked {session_type} session at {session_time}")
|
logging.info(f"Successfully booked {session_type} session at {session_time}")
|
||||||
else:
|
else:
|
||||||
logging.error(f"Failed to book {session_type} session at {session_time} - Session: {session}")
|
logging.error(f"Failed to book {session_type} session at {session_time} - Session: {session}")
|
||||||
|
# Send notification about the failed booking
|
||||||
|
session_details = f"{session['name_activity']} at {session_time.strftime('%Y-%m-%d %H:%M')}"
|
||||||
|
await self.notifier.notify_impossible_booking(session_details)
|
||||||
|
logging.info(f"Notified about impossible booking for {session_type} session at {session_time}")
|
||||||
|
|
||||||
async def run(self) -> None:
|
async def run(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -120,3 +120,21 @@ class SessionNotifier:
|
|||||||
|
|
||||||
if self.enable_telegram:
|
if self.enable_telegram:
|
||||||
await self.send_telegram_notification(telegram_message)
|
await self.send_telegram_notification(telegram_message)
|
||||||
|
|
||||||
|
async def notify_impossible_booking(self, session_details):
|
||||||
|
"""
|
||||||
|
Notify about an impossible session booking via email and Telegram.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
session_details (str): Details about the session that couldn't be booked
|
||||||
|
"""
|
||||||
|
# Create messages for both email and Telegram
|
||||||
|
email_message = f"Failed to book session: {session_details}"
|
||||||
|
telegram_message = f"Failed to book session: {session_details}"
|
||||||
|
|
||||||
|
# Send notifications through enabled channels
|
||||||
|
if self.enable_email:
|
||||||
|
self.send_email_notification(email_message)
|
||||||
|
|
||||||
|
if self.enable_telegram:
|
||||||
|
await self.send_telegram_notification(telegram_message)
|
||||||
Reference in New Issue
Block a user