This Python script allows you to send personalized messages and photos to a list of phone numbers via Telegram using the Pyrogram library. It reads contacts from an Excel file, sends messages with optional photos, and manages sending limits and flood controls automatically.
- Read phone numbers from an Excel file.
- Send a custom text message and a photo with a caption to each contact.
- Avoid sending messages to contacts messaged in the last 7 days.
- Automatically handles Telegram flood wait errors (
FLOOD_WAIT). - Limit the maximum number of messages sent per day.
- Delete contacts after sending messages to keep your contact list clean.
- Logs results in CSV and JSON files for easy tracking.
- Python 3.7+
- Pyrogram (
pip install pyrogram tgcrypto) - Pandas (
pip install pandas) - A Telegram API ID and API Hash (get from my.telegram.org)
-
Clone or download this repository.
-
Install required Python packages:
pip install pyrogram tgcrypto pandas
-
Prepare an Excel file (
.xlsx) containing a column namedphonewith phone numbers in local format (e.g.,09123456789). -
Obtain your
api_idandapi_hashfrom Telegram's API development tools.
Run the script and provide the requested inputs:
python sender.pyYou will be prompted to enter:
- api_id: Your Telegram API ID.
- api_hash: Your Telegram API Hash.
- session name: A name for your Pyrogram session (creates a session file).
- Excel file path: Path to your Excel file with phone numbers.
- Message text: The text message you want to send.
- Photo caption: Caption text for the photo.
- Photo file path: Path to the photo file to send.
- Maximum messages per day: Daily limit on messages to avoid spam/flood issues.
- The script reads phone numbers from the Excel file.
- Converts local phone numbers to international format (Iran country code
0098). - Skips numbers that received a message in the last 7 days.
- Sends the specified text message and photo to each number via Telegram.
- Deletes the contact after sending.
- Handles flood wait errors by pausing as required.
- Stops sending messages when the daily limit is reached.
- Saves detailed reports (
report.csvandreport_log.json) with statuses of all attempts.
- Make sure your phone number is connected and logged in via Pyrogram to send messages.
- Use this script responsibly and comply with Telegram's terms of service.
- Flood wait errors occur when you send too many messages too quickly; this script handles waiting automatically.
- The script assumes Iranian phone numbers starting with
0which are converted to international format0098.
This project is provided as-is without warranty. Use responsibly.
For questions or support, open an issue or contact me directly.