74 lines
2.0 KiB
Python
Executable File
74 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Main entry point for the CrossFit Booker application.
|
|
This script initializes the CrossFitBooker and starts the booking process.
|
|
"""
|
|
|
|
import logging
|
|
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 Booker and start the booking process.
|
|
"""
|
|
# Display ASCII art and username
|
|
with open('ascii.md', 'r') as f:
|
|
ascii_art = f.read()
|
|
print(ascii_art)
|
|
username = os.environ.get("CROSSFIT_USERNAME")
|
|
print(f"Username: {username}")
|
|
print()
|
|
|
|
# Set up logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(levelname)s - %(message)s',
|
|
handlers=[
|
|
logging.StreamHandler()
|
|
]
|
|
)
|
|
|
|
# Initialize components
|
|
auth_handler = AuthHandler(
|
|
str(os.environ.get("CROSSFIT_USERNAME")),
|
|
str(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
|
|
import asyncio
|
|
asyncio.run(booker.run())
|
|
|
|
if __name__ == "__main__":
|
|
main() |