问题描述
我将机器人电报放在不同的文件上,在这里我使用第二个电报_functions.js放置函数:这是我的index.js代码的一部分:
const Telegraf = require('telegraf'),t_functions = require('./utils/telegram_functions'),bot = new Telegraf(telegram_token);
const channel_id = 'mychannel id';
const { btnActions,wizard } = require('./utils/telegram_functions.js');
wizard(bot,channel_id);
btnActions(bot);
中心nel文件的问题:
const btnActions = bot => {
bot.action('testa_btn',(ctx) => {
console.log('enter wizard')
ctx.scene.enter('super-wizard');
});
botaction('avvia_btn_wizard',(ctx) => {
console.log("test")
return ctx.wizard.next();
});
}
const startBtn = Extra.markup((m) =>
m.inlineKeyboard([
[m.callbackButton('AVVIA','avvia_btn_wizard')],])
);
module.exports = {
....some functions.
wizard: async function (bot,channel_id) {
const superWizard = new WizardScene('super-wizard',ctx => {
let text = `My text`
ctx.telegram.sendMessage(ctx.from.id,o_functions.escapeReplace(text),{
parse_mode: 'MarkdownV2',reply_markup: startBtn.reply_markup
})
ctx.wizard.state.data = {};
return ctx.wizard.next()
},ctx => {
ctx.replyWithMarkdown('second step');
return ctx.wizard.next();
}
);
const stage = new Stage([superWizard]);
bot.use(session());
bot.use(stage.middleware());
}
然后使用以下命令通过命令运行场景
bot.command('testwizard',(ctx) => {
ctx.scene.enter('super-wizard');
});
工作完美,显示AVVIA按钮,然后如果我单击它,则在第二步通过。
如果我从其他功能运行向导(在具有其他按钮“ TESTA”的情况下需要执行的操作(在该功能中,我具有以下代码:
await bot.telegram.sendPhoto(
channel_id,{ source: filepath },{
caption: description.join("\n"),parse_mode: 'MarkdownV2',reply_markup: productButtons.reply_markup
}
)
它完美地工作,但是当我按“ AVVIA”时,它不起作用。
为什么不呢?我用一个作曲家和一个作曲家讨价还价,但是什么都没有。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)