- 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
-
-
Save bagaskarala/9876216f497a7847ed6f3e68ac146a2e to your computer and use it in GitHub Desktop.
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