Closed agusluques closed 9 months ago
Hey, I can't understand why this is not working
async function bootstrap() { const { BOT_TOKEN } = process.env; if (!BOT_TOKEN) throw new Error('"BOT_TOKEN" env var is required!'); const bot = new Bot<MyContext>(BOT_TOKEN); if (process.env.NODE_ENV !== 'production') { bot.use(generateUpdateMiddleware()); } // Postgresql const dbConfig = parseDBURL(process.env.DATABASE_URL); const client = new Client(dbConfig); await client.connect(); const storage = await PsqlAdapter.create({ tableName: 'sessions', client }); bot.use( session({ initial: () => ({}), storage: storage, }), ); const mainScene = new Scene<MyContext>('main'); mainScene.step(async ctx => { await ctx.reply('Entering main scene...'); }); mainScene.step(async ctx => { await ctx.reply('Enter your name:'); }); mainScene.wait('name').on('message:text', async ctx => { const name = ctx.message.text; if (name.toLowerCase() === 'john') { await ctx.reply(`Welcome, ${name}!`); ctx.scene.resume(); } else { await ctx.reply(`${name}, your are not welcome here.`); } }); const scenes = new ScenesComposer<MyContext>(mainScene); bot.use(scenes.manager()); bot.command('start', async ctx => { ctx.scenes.enter('main'); }); bot.use(scenes); bot.start({ onStart: botInfo => console.log(botInfo) }); } bootstrap();
I've written all the code in the same file in order to test the simplest example but still no working
2024-01-31T19:54:20.465Z fajmyl message Agus 6 /start: 17.817ms 2024-01-31T19:54:24.868Z fajmym message Agus 4 agus: 21.176ms
I've also tried with a step with an inline keyboard and the wait query-callback and doesn't work
SOLVE: see #18
Hey, I can't understand why this is not working
I've written all the code in the same file in order to test the simplest example but still no working
2024-01-31T19:54:20.465Z fajmyl message Agus 6 /start: 17.817ms 2024-01-31T19:54:24.868Z fajmym message Agus 4 agus: 21.176ms