一切都正常,但是在场景的第二阶段,i18n是没有定义的。i18n是注册的,机器人中的场景也是如此。
const createPostHere = new Scenes.WizardScene('createPostHere',
async (ctx) => {
ctx.wizard.state.post = {}
await ctx.reply(await ctx.i18n.t('createPost.promptTitle')) << everything works
ctx.wizard.next()
},
async (ctx) => {
ctx.wizard.state.post.title = ctx.message.text
await ctx.reply(await ctx.i18n.t('createPost.promptText')) << node crashes
ctx.wizard.next()
},所有注册
bot.use(stage.middleware());
bot.use(i18n.middleware())我真的不知道问题出在哪里
发布于 2022-06-10 13:01:12
async (ctx) => {
await ctx.replyWithHTML(
ctx.i18n.t('create-text')
)
ctx.scene.state.i18n = ctx.i18n
ctx.wizard.next()
},
async (ctx) => {
const { i18n } = ctx.scene.state
await ctx.replyWithHTML(i18n.t('create-details'))
await ctx.scene.leave()
}发布于 2022-11-24 10:07:55
您应该先使用i18n,然后再使用阶段中间件。如下所示:
bot.use(i18n.middleware());
bot.use(stage.middleware());https://stackoverflow.com/questions/72490164
复制相似问题