Reputation: 103
I am creating an application in Node Js that needs to read a message from a Telegram channel, does anyone know how to do it?
I found a lot of information about creating a Telegram Bot, but that does not help. To read information from a public Telegram channel, no bot should be needed.
Thanks and best regards.
Upvotes: 3
Views: 4824
Reputation: 16
You can do that by various different means (packages)
const { Telegraf } = require('telegraf');
const bot = new Telegraf('YOUR_BOT_TOKEN');
// The bot listens to all channel messages
bot.on('channel_post', (ctx) => {
const message = ctx.channelPost.text; // You can access message details here
console.log(`New message in channel: ${message}`);
// You can do further processing with the message
});
bot.launch();
...
async function eventPrint(event) {
// const message = event.message;
// ...
}
client.addEventHandler(eventPrint, new NewMessage({}));
// Channel posts sent by 'ctx.senderChat'
bot.on("channel_post");
Upvotes: 0
Reputation: 1130
You can use telegram mtproto api. some good efrence is here :
https://openbase.io/js/@mtproto/core/documentation
https://core.telegram.org/methods
Upvotes: 1