I created my telegram bot which should send every 15 minutes a message. Now it works with my own chat, because i writed my bot to start spam:
let job0
let job15
let job30
let job45
// Command to start scheduler.
bot.onText(/\/start_spam/, async message => {
try{
// Starts every 0 minute of hour.
job0 = schedule.scheduleJob('0 * * * *', async function(){
await bot.sendMessage(message.chat.id, spam_text).then()
});
// Starts every 15 minute of hour.
job15 = schedule.scheduleJob('15 * * * *', async function(){
await bot.sendMessage(message.chat.id, spam_text).then()
});
// Starts every 30 minute of hour.
job30 = schedule.scheduleJob('30 * * * *', async function(){
await bot.sendMessage(message.chat.id, spam_text).then()
});
// Starts every 45 minute of hour.
job45 = schedule.scheduleJob('45 * * * *', async function(){
await bot.sendMessage(message.chat.id, spam_text).then()
});
}catch (error){
console.log(error)
}
})
// Command to stop scheduler.
bot.onText(/\/stop_spam/, async message => {
try{
if (job0) {
await job0.cancel()
} else if (job15){
await job15.cancel()
} else if (job30){
await job30.cancel()
} else if (job45){
await job45.cancel()
}
}catch (error){
console.log(error)
}
});
Now i need this functional: I make command 'start_spam' and it writes not to me, but to some telegram group chat, how can i get this chat id or how to do it in another way?