125 lines
3.6 KiB
Markdown
125 lines
3.6 KiB
Markdown
# Crossfit Application
|
|
|
|
This is a Python application for managing Crossfit bookings and notifications. The application automates the process of booking Crossfit sessions and sends notifications via email and Telegram when a booking is successful.
|
|
|
|
## Features
|
|
|
|
- Automated booking of Crossfit sessions
|
|
- Email and Telegram notifications for successful bookings
|
|
- Configurable preferred sessions
|
|
- Retry logic for booking failures
|
|
- Detailed logging
|
|
|
|
## Prerequisites
|
|
|
|
- Docker
|
|
- Docker Compose
|
|
|
|
## Setup
|
|
|
|
1. Create a `.env` file based on `.env.example` and fill in the required credentials.
|
|
2. Build and run the application using Docker Compose:
|
|
|
|
```bash
|
|
docker-compose up --build
|
|
```
|
|
|
|
3. The application will run in a Docker container, and the logs will be stored in the `./log` directory.
|
|
|
|
## Usage
|
|
|
|
The application will automatically check for available sessions and book them based on your preferences. It will send notifications via email and Telegram when a booking is successful.
|
|
|
|
### Environment Variables
|
|
|
|
The following environment variables are required:
|
|
|
|
- `CROSSFIT_USERNAME`: Your Crossfit username
|
|
- `CROSSFIT_PASSWORD`: Your Crossfit password
|
|
- `EMAIL_FROM`: Your email address
|
|
- `EMAIL_TO`: Recipient email address
|
|
- `EMAIL_PASSWORD`: Your email password
|
|
- `TELEGRAM_TOKEN`: Your Telegram bot token
|
|
- `TELEGRAM_CHAT_ID`: Your Telegram chat ID
|
|
|
|
### Preferred Sessions
|
|
|
|
You can configure your preferred sessions in the `preferred_sessions.json` file. The preferred sessions are defined as a list of objects, where each object contains the day of the week, start time, and session name.
|
|
|
|
```json
|
|
[
|
|
{
|
|
"day_of_week": 4,
|
|
"start_time": "17:00",
|
|
"session_name_contains": "WEIGHTLIFTING"
|
|
},
|
|
{
|
|
"day_of_week": 5,
|
|
"start_time": "12:30",
|
|
"session_name_contains": "HYROX"
|
|
},
|
|
{
|
|
"day_of_week": 2,
|
|
"start_time": "18:30",
|
|
"session_name_contains": "CONDITIONING"
|
|
}
|
|
]
|
|
```
|
|
|
|
The application will automatically load the preferred sessions from this file. If the file is not found or contains invalid data, it will fall back to the default hardcoded sessions.
|
|
|
|
### Fields
|
|
|
|
- `day_of_week`: Integer representing the day of the week (0=Monday, 6=Sunday)
|
|
- `start_time`: String representing the start time in HH:MM format
|
|
- `session_name_contains`: String containing the name or part of the name of the session
|
|
|
|
## Files
|
|
|
|
- `Dockerfile`: Docker image definition
|
|
- `docker-compose.yml`: Docker Compose service definition
|
|
- `.env.example`: Example environment variables file
|
|
- `.dockerignore`: Docker ignore file
|
|
- `.gitignore`: Git ignore file
|
|
- `book_crossfit.py`: Main application script
|
|
- `crossfit_booker.py`: Crossfit booking script
|
|
- `session_notifier.py`: Session notification script
|
|
- `preferred_sessions.json`: Configuration file for preferred sessions
|
|
- `requirements.txt`: Python dependencies
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── Dockerfile
|
|
├── docker-compose.yml
|
|
├── .env.example
|
|
├── .dockerignore
|
|
├── .gitignore
|
|
├── book_crossfit.py
|
|
├── crossfit_booker.py
|
|
├── session_notifier.py
|
|
├── requirements.txt
|
|
├── preferred_sessions.json
|
|
└── log
|
|
└── crossfit_booking.log
|
|
```
|
|
|
|
## Testing the Telegram Notifier
|
|
|
|
To manually test the Telegram notifier functionality:
|
|
|
|
1. Ensure you have configured the Telegram credentials in the `.env` file:
|
|
```ini
|
|
TELEGRAM_TOKEN=your_telegram_bot_token
|
|
TELEGRAM_CHAT_ID=your_chat_id
|
|
```
|
|
|
|
2. Run the test script:
|
|
```bash
|
|
python test_telegram_notifier.py
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |