refactor: Remove CrossfitBooker class and simplify booking system

This commit is contained in:
kbe
2025-10-01 17:48:41 +02:00
parent 5f89af44aa
commit b6ea2a4ff1
12 changed files with 207 additions and 668 deletions

46
main.py
View File

@@ -5,11 +5,18 @@ This script initializes the CrossFitBooker and starts the booking process.
"""
import logging
from src.crossfit_booker import CrossFitBooker
import os
from src.auth import AuthHandler
from src.booker import Booker
from src.session_notifier import SessionNotifier
# Load environment variables
from dotenv import load_dotenv
load_dotenv()
def main():
"""
Main function to initialize the CrossFitBooker and start the booking process.
Main function to initialize the Booker and start the booking process.
"""
# Set up logging
logging.basicConfig(
@@ -20,11 +27,40 @@ def main():
]
)
# Initialize the CrossFitBooker
booker = CrossFitBooker()
# Initialize components
auth_handler = AuthHandler(
os.environ.get("CROSSFIT_USERNAME"),
os.environ.get("CROSSFIT_PASSWORD")
)
# Initialize notification system
email_credentials = {
"from": os.environ.get("EMAIL_FROM"),
"to": os.environ.get("EMAIL_TO"),
"password": os.environ.get("EMAIL_PASSWORD")
}
telegram_credentials = {
"token": os.environ.get("TELEGRAM_TOKEN"),
"chat_id": os.environ.get("TELEGRAM_CHAT_ID")
}
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")
notifier = SessionNotifier(
email_credentials,
telegram_credentials,
enable_email=enable_email,
enable_telegram=enable_telegram
)
# Initialize the Booker
booker = Booker(auth_handler, notifier)
# Run the booking process
booker.run()
import asyncio
asyncio.run(booker.run())
if __name__ == "__main__":
main()