Telegram 如何在telegraf库中使用电报官方api

Telegram 如何在telegraf库中使用电报官方api,telegram,telegram-bot,telegraf,telegraf.js,Telegram,Telegram Bot,Telegraf,Telegraf.js,我正在尝试使用和npm创建一个电报机器人 问题是我找不到一种方法来使用所有的电报方法,比如telegraf api中的channels.getFullChannel或channels.getMessages 电报官方文档中有一些方法我想使用,比如,但我不知道如何使用telegraf实例访问它 我将其用于我的代码: const Telegraf=require('Telegraf'); const bot=新的Telegraf(process.env.TOKEN); bot.command('lo

我正在尝试使用和npm创建一个电报机器人

问题是我找不到一种方法来使用所有的电报方法,比如telegraf api中的
channels.getFullChannel
channels.getMessages

电报官方文档中有一些方法我想使用,比如,但我不知道如何使用telegraf实例访问它

我将其用于我的代码:

const Telegraf=require('Telegraf');
const bot=新的Telegraf(process.env.TOKEN);
bot.command('logmessages',async(ctx)=>{
const res=ctx.telegrame.channels.getMessages(“@username”)
console.log(res)
ctx.reply(‘签出控制台’)
})
但在控制台中得到的是:

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)
我应该提到在官方文件中指出,机器人可以访问这些方法

我还做了测试

ctx.channels.getMessages('@username')

也不起作用

您好,您应该修改类构造函数并将channelMode设置为True

const bot =  new Telegraf(Token, {

channelMode: true
})

然后,您应该使用事件来获取类似这样的通道消息

bot.on('channel_post', (ctx) => {
 

console.log(ctx.channelPost);
})


它将记录所有频道中的每个频道帖子。您可以使用Simple if condition来记录您想要的频道

您好,您应该修改类构造函数并将channelMode设置为True

const bot =  new Telegraf(Token, {

channelMode: true
})

然后,您应该使用事件来获取类似这样的通道消息

bot.on('channel_post', (ctx) => {
 

console.log(ctx.channelPost);
})


它将记录所有频道中的每个频道帖子。您可以使用Simple if condition来记录您想要的这个频道

您有任何代码或错误可以添加吗?我编辑了这个问题!你有没有可以添加的代码或错误?我编辑了这个问题!这将在发送新消息时返回这些消息。。。我需要的是访问通道历史记录中的所有消息这会在发送新消息时返回这些消息。。。我需要的是访问通道历史记录中的所有消息