A lot of features #1

Merged
kbe merged 11 commits from develop into main 2025-07-20 14:32:07 +00:00
4 changed files with 38 additions and 12 deletions
Showing only changes of commit 28b8d57b27 - Show all commits

View File

@@ -1,14 +1,17 @@
# Configuration
CROSSFIT_USERNAME=Kevin8407
CROSSFIT_PASSWORD=9vx03OSE
# CrossFit booking credentials
CROSSFIT_USERNAME=your_username
CROSSFIT_PASSWORD=your_password
# Notification settings
ENABLE_EMAIL_NOTIFICATIONS=true
ENABLE_TELEGRAM_NOTIFICATIONS=false
EMAIL_FROM=no-reply@cyanet.fr
EMAIL_TO=kbataille@vivaldi.net
EMAIL_PASSWORD=BV3GzqHjsSx5A6TE
# Email notification credentials
SMTP_SERVER=mail.infomaniak.com
EMAIL_FROM=your_email
EMAIL_TO=recipient_email
EMAIL_PASSWORD=email_password
TELEGRAM_TOKEN=
TELEGRAM_CHAT_ID
# Telegram notification credentials
TELEGRAM_TOKEN=your_telegram_token
TELEGRAM_CHAT_ID=your_chat_id

6
.gitignore vendored
View File

@@ -178,3 +178,9 @@ poetry.toml
pyrightconfig.json
# End of https://www.toptal.com/developers/gitignore/api/python
# Docker
docker-compose.override.yml
docker-compose.yml
Dockerfile
.dockerignore

View File

@@ -1,8 +1,10 @@
import smtplib
import os
import logging
from email.message import EmailMessage
from telegram import Bot
class SessionNotifier:
"""
A class to handle notifications for session bookings.
@@ -39,6 +41,9 @@ class SessionNotifier:
Args:
message (str): The message content to be sent in the email
"""
logging.debug("Sending email notification")
logging.debug(f"Email credentials: {self.email_credentials}")
# Create an EmailMessage object
email = EmailMessage()
email.set_content(message)
@@ -51,9 +56,21 @@ class SessionNotifier:
email['Subject'] = 'Session Booking Notification'
# Send the email using smtplib
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
try:
smtp_server = os.environ.get("SMTP_SERVER")
if not smtp_server:
logging.error("SMTP server not configured in environment variables")
raise ValueError("SMTP server not configured")
with smtplib.SMTP_SSL(smtp_server, 465) as smtp:
logging.debug(f"Connecting to SMTP server: {smtp_server}")
smtp.login(self.email_credentials['from'], self.email_credentials['password'])
logging.debug("Logged in to SMTP server")
smtp.send_message(email)
logging.debug("Email sent successfully")
except Exception as e:
logging.error(f"Failed to send email: {str(e)}")
raise
def send_telegram_notification(self, message):
"""