Closed AndryFM closed 7 years ago
You can only use $ if the user has requested. You need to use tg.api.sendMessage(chatId, 'Hi');
You need to use tg.api.sendMessage(chatId, 'Hi');
@Z3nto thanks for this way!
but i have one more question:
when I write console.log(new Date());
in my app.js - I get 5 messages in console
also I got 5 messages in chat - when i write tg.api.sendMessage(chatId, 'Hi');
maybeits because
Telegram Master started, 4 CPUs found, 4 workers will start
but what i can do with it?
I found solution: https://github.com/Naltox/telegram-node-bot#clustering
const tg = new Telegram.Telegram('YOUR_TOKEN', {
workers: 1
})
tg.sendMessage(123, 'test message') //will be sent 2 times (one time on master and one time on worker)
tg.onMaster(() => {
tg.sendMessage(123, 'test message') //will be sent one time
})
thanks for all ;)
How i can send message without user request? I tried
tg.$.sendMessage(chatId, 'text');
but its dosnt work, i dont see info about it in docs