我正在尝试使用电报库和 npm创建电报机器人
问题是我找不到使用所有电报方法的方法,比如channels.getFullChannel
或channels.getMessages
在电报 API 内......
电报官方文档中有一些我想使用的方法,比如这个,但我不知道如何使用电报实例访问它。
我将其用于我的代码:
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')
})
但在控制台中得到的是:
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)
我应该提到,在官方文档中指出这些方法可以被 Bots 访问。
我也测试过
ctx.channels.getMessages('@username')
也没有用