A lot of features #1
@@ -2,6 +2,10 @@
|
|||||||
CROSSFIT_USERNAME=Kevin8407
|
CROSSFIT_USERNAME=Kevin8407
|
||||||
CROSSFIT_PASSWORD=9vx03OSE
|
CROSSFIT_PASSWORD=9vx03OSE
|
||||||
|
|
||||||
|
# Notification settings
|
||||||
|
ENABLE_EMAIL_NOTIFICATIONS=true
|
||||||
|
ENABLE_TELEGRAM_NOTIFICATIONS=true
|
||||||
|
|
||||||
EMAIL_FROM=kevin@mistergeek.fr
|
EMAIL_FROM=kevin@mistergeek.fr
|
||||||
EMAIL_TO=kbataille@vivaldi.net
|
EMAIL_TO=kbataille@vivaldi.net
|
||||||
EMAIL_PASSWORD=
|
EMAIL_PASSWORD=
|
||||||
|
|||||||
@@ -97,7 +97,16 @@ class CrossFitBooker:
|
|||||||
"chat_id": os.environ.get("TELEGRAM_CHAT_ID")
|
"chat_id": os.environ.get("TELEGRAM_CHAT_ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
self.notifier = SessionNotifier(email_credentials, telegram_credentials)
|
# Get notification settings from environment variables
|
||||||
|
enable_email = os.environ.get("ENABLE_EMAIL_NOTIFICATIONS", "true").lower() in ("true", "1", "yes")
|
||||||
|
enable_telegram = os.environ.get("ENABLE_TELEGRAM_NOTIFICATIONS", "true").lower() in ("true", "1", "yes")
|
||||||
|
|
||||||
|
self.notifier = SessionNotifier(
|
||||||
|
email_credentials,
|
||||||
|
telegram_credentials,
|
||||||
|
enable_email=enable_email,
|
||||||
|
enable_telegram=enable_telegram
|
||||||
|
)
|
||||||
|
|
||||||
def get_auth_headers(self) -> Dict[str, str]:
|
def get_auth_headers(self) -> Dict[str, str]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import smtplib
|
import smtplib
|
||||||
|
import os
|
||||||
from email.message import EmailMessage
|
from email.message import EmailMessage
|
||||||
from telegram import Bot
|
from telegram import Bot
|
||||||
|
|
||||||
@@ -12,18 +13,24 @@ class SessionNotifier:
|
|||||||
(e.g., 'from', 'to', 'password')
|
(e.g., 'from', 'to', 'password')
|
||||||
telegram_credentials (dict): Dictionary containing Telegram credentials
|
telegram_credentials (dict): Dictionary containing Telegram credentials
|
||||||
(e.g., 'token', 'chat_id')
|
(e.g., 'token', 'chat_id')
|
||||||
|
enable_email (bool): Whether to enable email notifications
|
||||||
|
enable_telegram (bool): Whether to enable Telegram notifications
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, email_credentials, telegram_credentials):
|
def __init__(self, email_credentials, telegram_credentials, enable_email=True, enable_telegram=True):
|
||||||
"""
|
"""
|
||||||
Initialize the SessionNotifier with email and Telegram credentials.
|
Initialize the SessionNotifier with email and Telegram credentials.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
email_credentials (dict): Email credentials for authentication
|
email_credentials (dict): Email credentials for authentication
|
||||||
telegram_credentials (dict): Telegram credentials for authentication
|
telegram_credentials (dict): Telegram credentials for authentication
|
||||||
|
enable_email (bool): Whether to enable email notifications
|
||||||
|
enable_telegram (bool): Whether to enable Telegram notifications
|
||||||
"""
|
"""
|
||||||
self.email_credentials = email_credentials
|
self.email_credentials = email_credentials
|
||||||
self.telegram_credentials = telegram_credentials
|
self.telegram_credentials = telegram_credentials
|
||||||
|
self.enable_email = enable_email
|
||||||
|
self.enable_telegram = enable_telegram
|
||||||
|
|
||||||
def send_email_notification(self, message):
|
def send_email_notification(self, message):
|
||||||
"""
|
"""
|
||||||
@@ -71,6 +78,9 @@ class SessionNotifier:
|
|||||||
email_message = f"Session booked: {session_details}"
|
email_message = f"Session booked: {session_details}"
|
||||||
telegram_message = f"Session booked: {session_details}"
|
telegram_message = f"Session booked: {session_details}"
|
||||||
|
|
||||||
# Send notifications through both channels
|
# Send notifications through enabled channels
|
||||||
self.send_email_notification(email_message)
|
if self.enable_email:
|
||||||
self.send_telegram_notification(telegram_message)
|
self.send_email_notification(email_message)
|
||||||
|
|
||||||
|
if self.enable_telegram:
|
||||||
|
self.send_telegram_notification(telegram_message)
|
||||||
Reference in New Issue
Block a user