feat(notifier): Add username display and improve config error handling
- Add CROSSFIT_USERNAME from .env to all Telegram notifications - Make session_config exit safely when config file is missing or invalid - Remove default hardcoded sessions, return empty list instead - Update unit tests to reflect new error handling behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,9 @@ class SessionNotifier:
|
||||
# Check environment variable for impossible booking notifications
|
||||
self.notify_impossible = os.environ.get("NOTIFY_IMPOSSIBLE_BOOKING", "true").lower() in ("true", "1", "yes")
|
||||
|
||||
# Get crossfit username from environment
|
||||
self.crossfit_username = os.environ.get("CROSSFIT_USERNAME", "User")
|
||||
|
||||
def send_email_notification(self, message):
|
||||
"""
|
||||
Send an email notification with the given message.
|
||||
@@ -114,8 +117,8 @@ class SessionNotifier:
|
||||
session_details (str): Details about the booked session
|
||||
"""
|
||||
# Create messages for both email and Telegram
|
||||
email_message = f"Session booked: {session_details}"
|
||||
telegram_message = f"Session booked: {session_details}"
|
||||
email_message = f"Session booked for {self.crossfit_username}: {session_details}"
|
||||
telegram_message = f"Session booked for {self.crossfit_username}: {session_details}"
|
||||
|
||||
# Send notifications through enabled channels
|
||||
if self.enable_email:
|
||||
@@ -133,8 +136,8 @@ class SessionNotifier:
|
||||
days_until (int): Number of days until the session
|
||||
"""
|
||||
# Create messages for both email and Telegram
|
||||
email_message = f"Session available soon: {session_details} (in {days_until} days)"
|
||||
telegram_message = f"Session available soon: {session_details} (in {days_until} days)"
|
||||
email_message = f"Session available soon for {self.crossfit_username}: {session_details} (in {days_until} days)"
|
||||
telegram_message = f"Session available soon for {self.crossfit_username}: {session_details} (in {days_until} days)"
|
||||
|
||||
# Send notifications through enabled channels
|
||||
if self.enable_email:
|
||||
@@ -164,8 +167,8 @@ class SessionNotifier:
|
||||
return
|
||||
|
||||
# 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}"
|
||||
email_message = f"Failed to book session for {self.crossfit_username}: {session_details}"
|
||||
telegram_message = f"Failed to book session for {self.crossfit_username}: {session_details}"
|
||||
|
||||
# Send notifications through enabled channels
|
||||
if self.enable_email:
|
||||
|
||||
Reference in New Issue
Block a user