0

I have a problem with Conversation. I wrote the following code in Conversation:

if (ctx.session.in_conversation == true) return;
 conversation.session.in_conversation = true;
 await ctx.replyWithChatAction("typing");
 await ctx.reply("Mahsulot nomini kiriting:", {
 reply_markup: cancelKeyboard,
 });
 const nameMsg = await conversation.waitFor(["message"], {
 otherwise: () => ctx.reply("Iltimos matn ko'rinishida kiriting!"),
 });
 const name = nameMsg.message?.text;
 if (name == "❌ Bekor qilish") {
 conversation.session.in_conversation = false;
 await ctx.reply("πŸ™…β€β™‚οΈ Amal bekor qilindi", { reply_markup: mainKeyboard });
 return;
 }
 await ctx.reply("Mahsulot haqida ma'lumot:");
 const descryptionMsg = await conversation.waitFor(["message"]);
 let descryption = descryptionMsg.message.text;
 await ctx.reply(`${descryption}`);
 conversation.session.in_conversation = false;
 return;

Conversation is stopping by itself without returning any error.

await ctx.reply("Mahsulot haqida ma'lumot:");

The text has been sent and the conversation is stuck. Where did I go wrong?

All are working until 2nd reply. But nothing is working after that. replies, conversation logs ... nothing. I solved the previous ones by completely deleting the conversation or rebuilding the project from 0.

marc_s
760k186 gold badges1.4k silver badges1.5k bronze badges
asked Feb 4, 2024 at 8:58

1 Answer 1

0

it happening because you are using multisession, it requires an additional initial value for conversations, here`s docs https://grammy.dev/plugins/conversations#installation-with-multi-sessions

bot.use(session({
 type: 'multi',
 isRegistred: {
 initial: () => false
 },
 isAdmin: {
 initial: () => false
 },
 conversation: {}
}))
answered Apr 10, 2024 at 19:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.