Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible for telegram bot to get messages from channel?

I added bot to channel as administrator but I have no messages in bot.on('message' callback. I have no problems with groups add bot privacy disabled. How to get upcoming channel messages?

const TelegramBot = require('node-telegram-bot-api');
let bot = new TelegramBot('xxxxxxxxxxxxxxxxxx', {polling: true});

bot.on('message', (msg) => {
    console.log(`${msg.from.username}:  ${msg.text} ${msg.location}`);
});
like image 255
Alexey Ryazhskikh Avatar asked Sep 15 '25 13:09

Alexey Ryazhskikh


1 Answers

as you can see in the documentation the right attribute of update is "channel_post" and not "message"

like image 137
91DarioDev Avatar answered Sep 17 '25 18:09

91DarioDev