This repository provides a template for creating a Telegram bot using Python, Flask, and Telethon. The project is structured to facilitate development, testing, and deployment using Docker.
- web/: Contains the Flask backend for the mini app.
- bot/: Contains the logic for bot commands written with Telethon.
- tasks/: Contains background cron tasks.
- core/: Contains common Python modules used across the project.
- docker-compose.yml: Docker Compose configuration for building and running all containers.
The core directory contains common Python modules used across the project. Ensure any shared logic or utilities are placed here for reusability.
- Python 3.x
- Docker
- Docker-compose
-
Clone the repository:
git clone git@github.com:Nellrun/TelegramBot.git cd TelegramBot -
Create a
.envfile in the root directory and add your API ID, API Hash, and Bot Token:API_ID=your_api_id API_HASH=your_api_hash BOT_TOKEN=your_bot_token WEB_URL=your_url_address
-
Get your API ID and API Hash from my.telegram.org.
-
Create a new bot and get the bot token from BotFather.
-
Update
.envwith your API ID, API Hash, and Bot Token:api_id = 'YOUR_API_ID' api_hash = 'YOUR_API_HASH' bot_token = 'YOUR_BOT_TOKEN' WEB_URL = 'http://127.0.0.1:8000/'
The project includes a docker-compose.yml file to streamline the process of building and running all components together.
To build and start all services:
docker-compose up --buildTo stop the services:
docker-compose downThis repository is intended to be a starting point for creating new Telegram bots. You can clone this repository and modify the files as needed to develop your own bots. The template includes a basic setup for a bot that sends a button linking to a web application, but it can be easily extended with additional functionality.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.