const { Telegraf } = require('telegraf')
const { TelegrafMongoSession } = require('telegraf-session-mongodb');
const bot = new Telegraf(process.env.TOKEN);
bot.on('message', (ctx) => ctx.reply(JSON.stringify({message:ctx.session})))
TelegrafMongoSession.setup(bot, process.env.MONGODB_URI)
.then((client) => bot.launch())
.catch((err) => console.log(`Failed to connect to the database: ${err}`));
when i write to bot, bot is sending to me a {}. so ctx.session is undefined. please help me. there is no error on console. i setted environment variables.
This is my code.
when i write to bot, bot is sending to me a
{}
. so ctx.session is undefined. please help me. there is no error on console. i setted environment variables.versions
mongodb schema url form:
mongodb://myhidden.domain:32771/myhiddendb