我有一个使用Node.js
框架的Telegraf
应用程序。我使用了本地会话和场景,并将所有数据持久保存到ctx.session...
现在,我想使用mongo会话,但是当我进入第二场景时,我得到了error
:
MongoError: Updating the path 'data.__scenes' would create a conflict at 'data.__scenes'
Code
如下:
const stage = new Stage([
languageScene, selectCharacterScene...]);
const bot = new Telegraf(config.token, {telegram: {webhookReply: true}});
MongoClient.connect(dbConfig.url, {useNewUrlParser: true}).then((client) => {
let database = client.db();
let session = new MongoSession(database);
session.setup().then(() => {
bot.use(session.middleware);
bot.use(stage.middleware());
bot.start((ctx) => {
ctx.scene.enter('languageScene')
});
})
});
bot.startPolling();