[Source Code ] Telegram Mass DM Bot- Telegram Bot Step by Step

I would usually recommend sending 5-10 messages per session. It means that you send 10 messages to 10 different users the program will stop automatically, that's a session.

I have used the same account to send messages to 20 users divided into 2 sessions of 10 users each.

The quality of the account is important, that it is old mainly.

Telegram detects the sending of mass messages if you use the same content, knowing this use this strategy to send different messages, if you use Link try to send messages to fewer users because it is easier to detect them.

The spam activity works based on a logic that only the spammer does, it means that if you send the same message to more than 5 people telegram will notice it and first it will flag your account - if you have not had restrictions before.


My intention is to share with the community but also that the community learns and obtains knowledge. If someone needs to use my code they can do it, there are no licenses or codes that do not allow you to use it unlimitedly.

Regardless of that, if someone then wants to convert it into exe or another type of executable is free to do so, the source code is there.

Also anyone can freely add / modify the code and adjust it to their needs
Thanks for the info! Does it mean that you do 20 messages per account in total and abandon it completely after that? I wonder if buying Premium for each account increases the limits and makes any economic sense
 
Thanks for the info! Does it mean that you do 20 messages per account in total and abandon it completely after that? I wonder if buying Premium for each account increases the limits and makes any economic sense
Telegram restrictions are made just for that, avoid spam and force the users to pay the Premium if they want to improve/increase their limits.
This mean that if you use Premium accounts your limitations will be higher than the normal accounts.
 
This is super useful, do you guys know what number of people is good to mass DM without getting banned
 
This is super usefull, i will build a UI to make more dynamic and get the api keys from a form.
 
Telegram restrictions are made just for that, avoid spam and force the users to pay the Premium if they want to improve/increase their limits.
This mean that if you use Premium accounts your limitations will be higher than the normal accounts.
I was stupid enough to pay for Premium for purchased accounts from my personal card, then accounts got banned anyway, and I had to reissue the card to cancel subscriptions lol xD

That’s how I learned Premium is not a magic bullet
 
Hey BHW!
As promised i want to share with you guys my source code of my Telegram Mass DM Bot.

First, our requirements to make it run. What we need Joshua? Simple boys. I made a easy to follow guide for you . There is no coding knowledge required but you will learn for sure how to use Python.
So, let's begin.

1 - Getting started and installing all the required programs.
Visual Studio Code for your OS (Windows, macOS, Linux )
Download and Install from https://code.visualstudio.com/download

2- Download and Install Python
https://www.python.org/downloads/

3- Open VSCode, create a new file you can name it main.py
4 - Open the file above created and copy + paste this code

Python:
# Start copying the code since this line if you don't understand Python
from telethon.sync import TelegramClient

# Function to login to Telegram
def login(api_id, api_hash, phone_number):
    client = TelegramClient('session_name', api_id, api_hash)
    client.connect()
    if not client.is_user_authorized():
        client.send_code_request(phone_number)
        client.sign_in(phone_number, input('Enter the code: '))
    return client

# Function to send message to list of usernames
def send_message(client, username_file, message):
    with open(username_file, 'r') as file:
        usernames = file.readlines()
        for username in usernames:
            try:
                client.send_message(username.strip(), message)
                print(f"Message sent to {username.strip()} successfully!")
            except Exception as e:
                print(f"Failed to send message to {username.strip()}: {e}")

# Main function
def main():
    # Input your Telegram API credentials
    api_id = 'xxxxxxxxxx'
    api_hash = 'xxxxxxxxxxxxx'
    phone_number = 'xxxxxxxxxx'

    # Login to Telegram
    client = login(api_id, api_hash, phone_number)

    # Send message
    username_file = 'usernames.txt'  # Name of the text file containing usernames
    message = 'MY NAME IS JOSHUA AND THIS IS MY MASS DM BOT WORKING. Congrats you make it!'  # Message to be sent
    send_message(client, username_file, message)

if __name__ == '__main__':
    main()

As simple as that but there are points that must be filled, we are not ready to run yet...Just follow me below.

5 - Adding the text file where the target usernames are
Create a new file for the usernames to send messages, i call it usernames.txt in the code so you can use the same name .
If you use another file name , you must modify the above code then but i've tagged the whole code so is more easier to read.

6 - Extracting API ID, HASH ID for accounts and setting up the python file.
Go to https://my.telegram.org ( You must login )
Create an app
Fill in the app details
Extract the api ID
Extract the api hash
Input the api id in the main.py
Input the api hash in the main.py
Input the account number in the main.py


7- Open the Python Terminal through VSCode

8 - Installing required libraries, only telethon. I tried to make the code easier to install so with telethon everything is covered.
First type

pip3 = pip / May change depend on your OS

9 - With all the steps above filled now you are ready to run the code just typing

Python3 = python / May change depend on your OS

TAKE IN MIND BEFORE RUNNING
All the code is quite optimized and updated but for BULK tasks i would recommend to use bulk accounts. Do not use your own account to send 100's of DMs because I can't guarantee you won't get your accounts flagged or banned.

IF you need any help kindly post here and i'll assist you.

PS : This is not a sales thread and this tool is shared for FREE neither I'm not distributing this to catch customers as i'm my tools are not available to buy anymore.

With this said, enjoy.
J.J
Not too bad, thanks for sharing , there's another tg bot someone posted here long time ago, py 3.13v which extracts usernames and such from groups.

Of course, this will lead to account bans and you need api keys from tg every time, but if the roi is good, then it's all worth it
 
I was stupid enough to pay for Premium for purchased accounts from my personal card, then accounts got banned anyway, and I had to reissue the card to cancel subscriptions lol xD

That’s how I learned Premium is not a magic bullet
Not everyone have the same experience of course.

Not too bad, thanks for sharing , there's another tg bot someone posted here long time ago, py 3.13v which extracts usernames and such from groups.

Of course, this will lead to account bans and you need api keys from tg every time, but if the roi is good, then it's all worth it
As someone that made a profit with this same code in the past I can say , it worth the try.

If you are not coding friendly there is step by step guide to get started.

Feel free to improve the code as your needs.
 
Appreciate the share man. For anyone actually trying to scale this, I've found that routing the Telethon sessions through residential proxies using the python-socks library is the only way to avoid a quick IP ban. Also, sticking a random sleep delay between 60 and 120 seconds in that loop is basically mandatory if you want the accounts to survive more than a few hours.
 
Appreciate the share man. For anyone actually trying to scale this, I've found that routing the Telethon sessions through residential proxies using the python-socks library is the only way to avoid a quick IP ban. Also, sticking a random sleep delay between 60 and 120 seconds in that loop is basically mandatory if you want the accounts to survive more than a few hours.
Why not simply using mobile data with IP rotation between accounts? That's what I do and it's pretty simple and cheap. Just one phone with SIM card, no proxies hustle. Though I understand my scale is quite low (~10 accs) but for this size it work good.
 
Back
Top