A web-based control panel for managing a Telegram bot that automatically posts comments in channels. Built with Flask for the web interface and Telethon for interacting with the Telegram API.
- Web-Based UI: Easy-to-use interface to manage all bot functions.
- Secure Access: The control panel is protected by a password configured in a
config.jsonfile. - Multi-Account Management: Add and remove multiple Telegram accounts to use for commenting.
- Dynamic Comment List: Add and remove comments that the bot will choose from randomly.
- Start/Stop Control: Easily start and stop the commenting process.
- Live Logging: View the bot's recent activity directly in the web UI.
- Python 3.10+
- A Telegram account
- Telegram
API_IDandAPI_HASH. You can get these from my.telegram.org.
-
Clone the repository:
git clone https://github.com/m-eti/CommentBot cd CommentBot -
Create a
requirements.txtfile: This project depends on Flask and Telethon. Create a file namedrequirements.txtwith the following content:flask telethon -
Install dependencies:
pip install -r requirements.txt
-
Start the application:
gunicorn --bind 0.0.0.0:8000 wsgi:application --reload
The first time you run the application, it will create a
config.jsonfile in the root directory with default values. -
Configure the application: Open the newly created
config.jsonfile and edit it:- Set your
API_IDandAPI_HASHobtained from Telegram. - Change the default
PASSWORDfrom"admin"to something secure.
Example
config.json:{ "PASSWORD": "your_secure_password", "API_ID": "1234567", "API_HASH": "your_api_hash", "accounts": {}, "comments": [] } - Set your
-
Access the Control Panel: Open your web browser and navigate to
http://127.0.0.1:5000. You will be prompted to log in with the password you set inconfig.json.
-
Add Account:
- Enter a phone number and click "Get Verification Code".
- Telegram will send a code to that account.
- Enter the phone number, the received code, and the account's 2FA password (if it has one) and click "Add Account".
-
Add Comment: Enter the text for a new comment and click "Add Comment". The bot will randomly pick from this list.
-
Control: Use the "Start" and "Stop" buttons to control the bot's commenting activity.
-
Manage Accounts/Comments: You can delete accounts and comments from their respective lists using the "Delete" buttons.
To run the included tests, you'll need pytest.
- Install testing dependencies:
pip install pytest
- Run the test suite:
pytest