This project automates sending messages to a Telegram group at specific times and handles admin replies based on predefined responses.
- Schedule messages to be sent at specific times.
- Automatically reply to user messages with predefined answers.
- Supports multiple Telegram accounts.
- Python 3.8 or higher
- A Telegram account and API credentials (API ID and API Hash)
To use this project, you need to obtain your Telegram API credentials (API ID and API Hash). Follow these steps:
- Go to my.telegram.org.
- Log in with your Telegram account.
- Click on "Create Application".
- Fill in the required details (App title, Short name, etc.).
- Once created, you will see your API ID and API Hash. Save these credentials.
This project uses the following Python libraries:
telethon
(for interacting with Telegram's API)pandas
(for handling CSV files)python-dotenv
(for managing environment variables)pytz
(for timezone handling)
Install them using the following command:
pip install telethon pandas python-dotenv pytz
Clone the repository to your local machine:
git clone https://github.com/rifatxtra/multiple-telegram-auto-scheduling-bot.git
cd telegram-auto-scheduler
-
Create a
.env
file in the project root directory. -
Add your Telegram API credentials and phone numbers to the
.env
file:ADMIN_PHONE_NUMBER= ADMIN_API_ID= ADMIN_API_HASH= ACCOUNT1_PHONE_NUMBER= ACCOUNT1_API_ID= ACCOUNT1_API_HASH= ACCOUNT2_PHONE_NUMBER= ACCOUNT2_API_ID= ACCOUNT2_API_HASH= ACCOUNT3_PHONE_NUMBER= ACCOUNT3_API_ID= ACCOUNT3_API_HASH=
Enter phone number with country code eg: +8801******** if you are from usa your number will look like: +18005555555 dont use any space or symbol except + If you have more user simply add withy these format Replace the placeholders with your actual credentials.
-
Create CSV files for each account and admin with the required data.
-
Example format for
admin_responses.csv
:question,answer "Good Morning!","Good Morning! How are you doing today?" "What is State1?","State1 is an innovative ecosystem..."
-
Example format for
carlos.csv
(for scheduled messages):codetime,question "08:00","Good Morning!" "12:00","Good Afternoon!"
Run the script using the following command:
python test.py
- Update the
group_username
variable in theschedule_messages
function to your Telegram group username. - Modify the CSV files to customize questions and answers.
This project is licensed under the MIT License. See the LICENSE file for details.
- Ensure the
.env
file is added to.gitignore
to avoid uploading sensitive data to GitHub. - The script uses the Telethon library, which requires an active internet connection to interact with Telegram's API.