- create bot in
@BotFather
, get the token. - add our bot to group.
- get group chat id, by adding
@RawDataBot
. After got the id, remove this bot from group. - fill some data in script.
- run the script in online compiler, example: https://www.typescriptlang.org/play.
Last active
August 4, 2022 09:34
Star
You must be signed in to star a gist
Telegram broadcast multiple groups using bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chatIdList = ['xxx','yyy','zzz']; | |
const botToken = 'xxx'; | |
const message = 'your message here'; | |
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
(async () => { | |
for (let i = 0; i < chatIdList.length; i++) { | |
fetch(`https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatIdList[i]}&text=${message}&parse_mode=markdown`) | |
.then(response => response.json()) | |
.then(response => { | |
console.log({ status: `${chatIdList[i]}: ${response.ok}` }); | |
}).catch(err => { | |
console.log('error! ', err); | |
}); | |
await sleep(1000); | |
} | |
console.log("done"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment