⚠️ Disclaimer: This project is created for educational purposes only.
It is meant to demonstrate how to use the Telegram API with Python in a safe and responsible way.
Do not use this project to send unsolicited messages, spam, or perform any harmful actions.
The author is not responsible for misuse of this code.
This repository provides a terminal UI to send automatic text messages and media randomly, to a specified person in telegram. The goals of writing this project are:
- Work with the Telegram API.
- Send messages programmatically.
- Understand the basics of automation in Python.
It is not a production-suitable bot and must only be used in controlled, private environments for practice and learning purposes.
- Telegram Terms of Service prohibit unsolicited or bulk messaging. Violating these rules can result in account bans.
- GitHub Acceptable Use Policy does not allow harmful software. This project is structured as an educational project to stay compliant.
- Use only with test accounts.
- Never use this with real users or in ways that could be considered spam.
Here, I explain all options of the menu and some details in the app.
- Clone the app from this repo to your local machine.
- Open a terminal in the path of the cloned app.
- Create a
venvby entering this in the terminal:
python -m venv .venv - After the
venvis created, activate it by entering this in the terminal:
.venv/Scripts/activate - Then you have to install the packages in
requirements.txtby entering this in the terminal:
pip install -r requirements.txt - Now you're ready! When your
venvis activated, enterpython app.pyto runapp.pywhich has the main functionality of the project. - After you're done, you can deactivate your
venvby entering this in the terminal:deactivate
When you start the app, an initialization method will be executed.
This initialization method creates you a data folder(if it doesn't exist) that includes these files and folders:
messages.jsonfor storing your added messagesdata.jsonto store your added accountsmediafolder for storing media you want to send.
There is a folder called sessions that will be automatically created in case that it doesn't exist. After adding an account, the account's session will be stored in this folder and after deleting an account, the created session will be deleted from this folder.
To start using the app, you must get a telegram api and get its API ID and API Hash which you can get here: https://my.telegram.org/apps
After you created a telegram api, select Add a Telegram User option from the menu. You will be asked to enter API ID, API Hash and Phone Number. After that, if the info you entered is correct, a code will be sent to your telegram PV by telegram itself. After you enter that code and confirming the adding account, the account will be added to the app and a session will be created for your account.
This option simply shows the username, API ID, API Hash and Phone Number of added users.
With this option, you can delete an added telegram user from the app. After deleting a user from the app, its data will be removed and the users session will be removed from the sessions folder.
With this option, you can add a message and it will be stored in the messages.json file in data folder and you can choose the added message later to be sent.
NOTE: This option is only for adding text messages. If you want to add media, you have to go to data folder, then go to media folder and place the media you want to add.
You can see the added text messages and media with this option.
You can delete only added text messages, with this option. For deleting medias, like adding them, simply go to data/media path from root of the project and delete the media you want.
This is the main option of this bot. By selecting this, you will be asked to choose the accounts that you want to message with, you can choose one or more account.
Then, you will be asked to choose the text messages and media to send. Note that the selected text and media messages will be sent randomly.
After that, you have to enter the telegram username of the user that you want to send message.
Then, you will be asked the number of messages that you want to send. Please note that the selected number is the number of messages that will be sent with each account.
After that, sending messages will be started. To emphasize that this is not a spamming process, after that a message is sent, there will be a pause between 1 to 5 seconds.