Skip to content

A Python script using Pyrogram to send bulk Telegram messages and photos to contacts from an Excel file. It handles flood waits, limits daily sends, avoids duplicate messaging within 7 days, and logs all results for easy tracking.

Notifications You must be signed in to change notification settings

mehdi-jahani/telegram_message_sender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Telegram Bulk Messaging Script with Pyrogram

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.


Features

  • 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.

Requirements

  • Python 3.7+
  • Pyrogram (pip install pyrogram tgcrypto)
  • Pandas (pip install pandas)
  • A Telegram API ID and API Hash (get from my.telegram.org)

Setup

  1. Clone or download this repository.

  2. Install required Python packages:

    pip install pyrogram tgcrypto pandas
  3. Prepare an Excel file (.xlsx) containing a column named phone with phone numbers in local format (e.g., 09123456789).

  4. Obtain your api_id and api_hash from Telegram's API development tools.


Usage

Run the script and provide the requested inputs:

python sender.py

You 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.

How It Works

  • 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.csv and report_log.json) with statuses of all attempts.

Notes

  • 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 0 which are converted to international format 0098.

License

This project is provided as-is without warranty. Use responsibly.


Contact

For questions or support, open an issue or contact me directly.

About

A Python script using Pyrogram to send bulk Telegram messages and photos to contacts from an Excel file. It handles flood waits, limits daily sends, avoids duplicate messaging within 7 days, and logs all results for easy tracking.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages