Compare commits
4 Commits
ea05c847ba
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc5796d989 | ||
|
|
c073006592 | ||
|
|
ed7165632a | ||
|
|
d809dd6753 |
54
README.md
54
README.md
@@ -12,12 +12,16 @@ This is a Python application for managing Crossfit bookings and notifications. T
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- Docker
|
- Python 3.8+
|
||||||
- Docker Compose
|
- Docker (optional)
|
||||||
|
- Docker Compose (optional)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
1. Create a `.env` file based on `.env.example` and fill in the required credentials.
|
1. Create a `.env` file based on `.env.example` and fill in the required credentials.
|
||||||
|
|
||||||
|
### Running with Docker (Recommended)
|
||||||
|
|
||||||
2. Build and run the application using Docker Compose:
|
2. Build and run the application using Docker Compose:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -26,6 +30,20 @@ docker-compose up --build
|
|||||||
|
|
||||||
3. The application will run in a Docker container, and the logs will be stored in the `./log` directory.
|
3. The application will run in a Docker container, and the logs will be stored in the `./log` directory.
|
||||||
|
|
||||||
|
### Manual Setup
|
||||||
|
|
||||||
|
2. Install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run the application:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## 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.
|
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.
|
||||||
@@ -76,32 +94,46 @@ The application will automatically load the preferred sessions from this file. I
|
|||||||
|
|
||||||
## Files
|
## Files
|
||||||
|
|
||||||
|
- `main.py`: Main entry point for the application
|
||||||
|
- `src/`: Source code directory
|
||||||
|
- `auth.py`: Authentication handling
|
||||||
|
- `booker.py`: Main booking logic
|
||||||
|
- `session_manager.py`: Session management
|
||||||
|
- `session_notifier.py`: Notification handling
|
||||||
|
- `session_config.py`: Session configuration
|
||||||
|
- `tools/`: Utility scripts
|
||||||
|
- `scripts/`: Additional scripts
|
||||||
|
- `test/`: Test files
|
||||||
- `Dockerfile`: Docker image definition
|
- `Dockerfile`: Docker image definition
|
||||||
- `docker-compose.yml`: Docker Compose service definition
|
- `docker-compose.yml`: Docker Compose service definition
|
||||||
- `.env.example`: Example environment variables file
|
- `.env.example`: Example environment variables file
|
||||||
- `.dockerignore`: Docker ignore file
|
- `.dockerignore`: Docker ignore file
|
||||||
- `.gitignore`: Git ignore file
|
- `.gitignore`: Git ignore file
|
||||||
- `book_crossfit.py`: Main application script
|
- `preferred_sessions.json.example`: Example configuration file for preferred sessions
|
||||||
- `crossfit_booker.py`: Crossfit booking script
|
|
||||||
- `session_notifier.py`: Session notification script
|
|
||||||
- `preferred_sessions.json`: Configuration file for preferred sessions
|
|
||||||
- `requirements.txt`: Python dependencies
|
- `requirements.txt`: Python dependencies
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
|
├── main.py
|
||||||
|
├── src/
|
||||||
|
│ ├── auth.py
|
||||||
|
│ ├── booker.py
|
||||||
|
│ ├── session_manager.py
|
||||||
|
│ ├── session_notifier.py
|
||||||
|
│ └── session_config.py
|
||||||
|
├── tools/
|
||||||
|
├── scripts/
|
||||||
|
├── test/
|
||||||
├── Dockerfile
|
├── Dockerfile
|
||||||
├── docker-compose.yml
|
├── docker-compose.yml
|
||||||
├── .env.example
|
├── .env.example
|
||||||
├── .dockerignore
|
├── .dockerignore
|
||||||
├── .gitignore
|
├── .gitignore
|
||||||
├── book_crossfit.py
|
├── preferred_sessions.json.example
|
||||||
├── crossfit_booker.py
|
|
||||||
├── session_notifier.py
|
|
||||||
├── requirements.txt
|
├── requirements.txt
|
||||||
├── preferred_sessions.json
|
└── log/
|
||||||
└── log
|
|
||||||
└── crossfit_booking.log
|
└── crossfit_booking.log
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ services:
|
|||||||
- TELEGRAM_TOKEN=${TELEGRAM_TOKEN}
|
- TELEGRAM_TOKEN=${TELEGRAM_TOKEN}
|
||||||
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}
|
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}
|
||||||
volumes:
|
volumes:
|
||||||
- ./log:/app/log
|
- ./:/app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
19
main.py
19
main.py
@@ -18,14 +18,6 @@ def main():
|
|||||||
"""
|
"""
|
||||||
Main function to initialize the Booker and start the booking process.
|
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
|
# Set up logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
@@ -35,6 +27,17 @@ def main():
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Display ASCII art and username
|
||||||
|
try:
|
||||||
|
with open('ascii.md', 'r') as f:
|
||||||
|
ascii_art = f.read()
|
||||||
|
print(ascii_art, flush=True)
|
||||||
|
username = os.environ.get("CROSSFIT_USERNAME")
|
||||||
|
print(f"Username: {username}", flush=True)
|
||||||
|
print(flush=True)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Error displaying ASCII: {e}")
|
||||||
|
|
||||||
# Initialize components
|
# Initialize components
|
||||||
auth_handler = AuthHandler(
|
auth_handler = AuthHandler(
|
||||||
str(os.environ.get("CROSSFIT_USERNAME")),
|
str(os.environ.get("CROSSFIT_USERNAME")),
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"day_of_week": 0,
|
|
||||||
"start_time": "17:45",
|
|
||||||
"session_name_contains": "WEIGHTLIFTING LOUVRE 3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"day_of_week": 4,
|
|
||||||
"start_time": "17:00",
|
|
||||||
"session_name_contains": "CONDITIONING LOUVRE 3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"day_of_week": 5,
|
|
||||||
"start_time": "12:30",
|
|
||||||
"session_name_contains": "HYROX"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"day_of_week": 5,
|
|
||||||
"start_time": "12:30",
|
|
||||||
"session_name_contains": "CONDITIONING"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Reference in New Issue
Block a user