【发布时间】:2021-10-23 15:48:41
【问题描述】:
我有一个错误。我不明白如何将消息从电报机器人转发到频道。我用telegraf.js 发送第一条消息后,想发送第二条,转发第一条。第一张照片是机器人中的答案。第二张照片是进入频道的。
我实现的代码本身:
bot.on('message', async (ctx) => {
const getFilmId = await kinoInfo(ctx.message.text);
const infoFilm = getFilmId.data.data;
const id = infoFilm.filmId;
const name = infoFilm.nameRu;
ctx.reply(name, {
reply_markup: {
inline_keyboard: [
[{ text: `Watch`, url: 'https://www.instagram.com/' }],
[{ text: 'Telegram channel 1', callback_data: 'ONE' }],
],
},
});
bot.on('callback_query', (ctx) => {
const data = ctx.update.callback_query.data;
if (data === 'ONE') {
postToChannel(ctx);
}
});
const postToChannel = (ctx) => {
ctx.telegram.sendMessage('@fgdsfsdfsd', name, {
parse_mode: 'html',
reply_markup: {
inline_keyboard: [[{ text: `Watch`, url: 'https://www.instagram.com/' }]],
},
});
};
});
【问题讨论】:
标签: javascript node.js telegram-bot telegraf