关于Telegraf的Mongodb会话抛出错误

时间:2018-07-25 14:17:14

标签: mongodb telegraf

我有一个使用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();

0 个答案:

没有答案