This project is a Telegram bot that leverages a XGBoost neural network model to predict the outcomes of Dota 2 matches. The bot provides users with real-time predictions based on current match data, making it a useful tool for Dota 2 enthusiasts and analysts.
- Real-Time Predictions: Predict match outcomes using a trained neural network model.
- Data Integration:
- Training data sourced from the OpenDota API for historical match results.
- Current match data fetched using the Steam API.
- User-Friendly Interface: Interactive Telegram bot interface for easy access to predictions and match information.
- Programming Language: Python
- Machine Learning Framework: XGBoost
- APIs: OpenDota API, Steam API
- Bot Framework: python-telegram-bot
Running the bot with Docker Compose is a great way to manage dependencies and ensure that all services are running consistently across different environments. Here’s how to do it:
-
Ensure Docker and Docker Compose are Installed: Make sure you have Docker and Docker Compose installed on your machine.
-
Prepare Your Project: Your project directory should contain the following files:
docker-compose.yml
Dockerfile
for the predictor service- Your source code files (including
start.py
)
-
Create a
.env
File: Ensure you have a.env
file with your environment variables, including your OpenDota API key, Steam API key, Telegram Bot token, and database credentials. -
Build and Run the Services: Open your terminal, navigate to your project directory, and run the following command:
docker-compose up --build
This command will build your predictor image (if necessary) and start both the PostgreSQL database and the predictor bot in separate containers.
-
Accessing the Bot: Once everything is up and running, you can interact with your Telegram bot as usual.
If you prefer to run the predictor without Docker, you can do so by executing start.py
directly on your local machine. Here’s how:
-
Install Required Dependencies: Make sure you have all the required dependencies installed. You can use a virtual environment for this:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` pip install -r requirements.txt
-
Set Up PostgreSQL: Ensure you have a PostgreSQL server running. You can install PostgreSQL locally or use a hosted service. Make sure to create a database and user that match the credentials in your
.env
file. -
Create a
.env
File: Just like with Docker, you need a.env
file. It should contain:OPENDOTA_KEY=your_actual_opendota_api_key STEAM_API_KEY=your_actual_steam_api_key TELEGRAM_KEY=your_actual_telegram_bot_token DB_HOST=localhost DB_USER=myuser DB_PASSWORD=mypassword DB_NAME=mydatabase
-
Run the Bot: Now, you can run your bot with:
python start.py
-
Accessing the Bot: Just like with Docker, you can interact with your Telegram bot.
-
Docker Compose: Good for consistency and ease of deployment across different environments. It manages all dependencies, including PostgreSQL, automatically.
-
Local Execution: Useful for development or testing without Docker. Ensure you have all the services running locally.
Once the bot is running, users can interact with it through Telegram to receive predictions for ongoing Dota 2 matches. The bot will provide match details and predicted outcomes based on the trained model.
Below is a high-level system schema that illustrates how the components interact in the Dota 2 predictor bot:
flowchart TD
%% User interaction with Telegram bot
User -->|Sends match query| TelegramBot
%% TelegramBot passes the request to Backend
TelegramBot -->|Receives query| Backend
%% Backend fetches data from external APIs
Backend -->|Fetch match/player data| OpenDotaAPI
Backend -->|Fetch match/player data| SteamAPI
%% Data preprocessing
Backend -->|Preprocesses data| PreprocessingEngine
PreprocessingEngine -->|Feeds preprocessed data| XGBoostModel
%% Model prediction and returning result to user
XGBoostModel -->|Returns prediction| Backend
Backend -->|Sends result| TelegramBot
TelegramBot -->|Displays result| User
%% Data flow from OpenDota and Steam APIs to Preprocessing Engine
OpenDotaAPI -->|Returns match/player data| Backend
SteamAPI -->|Returns player data| Backend
Here’s the ERD showing the key entities and their relationships within the system:
erDiagram
MATCH {
int match_id
date match_date
int duration
string outcome
}
PLAYER {
int player_id
string player_name
int rank
}
TEAM {
int team_id
string team_name
}
HERO {
int hero_id
string hero_name
string hero_role
}
PREDICTION_MODEL {
int model_id
string model_name
string algorithm
float accuracy
}
TEAM ||--o{ PLAYER : has
PLAYER ||--o{ MATCH : participates_in
MATCH ||--o{ TEAM : involves
PLAYER ||--o{ HERO : plays
PREDICTION_MODEL ||--|{ MATCH : uses_data_from
Contributions are welcome! Please open an issue or submit a pull request for any enhancements, bug fixes, or new features.
This project is licensed under the MIT License. See the LICENSE file for details.
- My Medium Article Part 1
- My DOU Article Part 1🇺🇦
- My Medium Article Part 2
- OpenDota API
- Steam API
- XGBoost
- pyTelegramBotAPI