Send different global message in telegram bot

1.3k views Asked by At

I'm writing telegram bot but i have a problem.I have a database that store my users's user ID

After finishing code and running bot , when my bot users become more i can send them commercial post and earn money ,or when i add new features to my bot and i want to send message to all users that this new feature added to bot , but my problem is here that i don't know how to send global message when my code is running.I don't want to stop my code and write that line to send global message and then restart my code.

Is there any solution for this problem?Can i use bot token twice?for example on when on server my code is running , i write another code to send message to all users and run it beside the main code?

If this way does not work , so what should i do for that?

1

There are 1 answers

1
newsha On BEST ANSWER

Telegram's bot API itself does not have any method for sending out bulk messages to your users. You may want to read this: "How can I message all of my bot's subscribers at once?"

If you wish to notify all your subscribers at once you have to store their chat_ids and send out individual messages. When doing this you do not have to stop any code running on your server. You can write seperate code for bulk notification and run it only once.

So I think you already have the right idea.