I'm trying to create a telegram bot using telegraf library and npm
and the problem is I can't find a way to use all telegram methods like channels.getFullChannel
or channels.getMessages
inside telegraf api...
there are methods in telegram official docs that I want to use them, like this one, but I don know how to access it with telegraf instance.
i use this for my code:
const Telegraf = require('Telegraf');
const bot = new Telegraf(process.env.TOKEN);
bot.command('logmessages', async (ctx) => {
const res = ctx.telegram.channels.getMessages('@username')
console.log(res)
ctx.reply('check out console')
})
but what is get in the console is:
TypeError: Cannot read property 'getMessages' of undefined
at /app/node_modules/telegraf/composer.js:143:56
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 0)
I should mention that in the official docs is pointed that these methods are accessible by Bots.
I also tested
ctx.channels.getMessages('@username')
didn't work either
hello u should modify Your Class Constructor and set channelMode True
})
then u should use event for geting channel message something like that
})
it will log every channel post in all channel. You can use Simple if condition for log this channel u want