A lot of features #1
19
.env.example
19
.env.example
@@ -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
6
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -11,4 +11,4 @@ if __name__ == "__main__":
|
||||
|
||||
# Start continuous booking loop
|
||||
booker.run()
|
||||
logging.info("Script completed")
|
||||
logging.info("Script completed")
|
||||
@@ -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:
|
||||
smtp.login(self.email_credentials['from'], self.email_credentials['password'])
|
||||
smtp.send_message(email)
|
||||
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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user