Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation doesn't end when maxMillisecondsToWait reaches timeout when use waitFor('message:text') #90

Closed
gomez-git opened this issue Sep 26, 2023 · 2 comments · Fixed by #122
Labels
bug Something isn't working v2 Needs to be fixed before v2

Comments

@gomez-git
Copy link

gomez-git commented Sep 26, 2023

This simple echo bot works: you type /start, bot sends you hello, you type hello, bot sends you hello, when you type hello again, bot didn't answer

node 18.18.0
grammy 1.19.0
conversations 1.1.2

snippet to reproduce the bag:

import { Bot, session } from 'grammy';
import { conversations, createConversation } from '@grammyjs/conversations';

const token = '';
const bot = new Bot(token);

bot.use(session({ initial: () => ({}) }));

bot.use(conversations());

bot.use(createConversation(async (conversation, ctx) => {
        await ctx.reply('hello');
        ctx = await conversation.waitFor('message:text'); // Don't stops here
        await ctx.reply(ctx.msg.text);
        ctx = await conversation.wait(); // Stops here
        await ctx.reply(ctx.msg.text);
}, {
        id: 'default',
        maxMillisecondsToWait: 0,
}));

bot.command('start', (ctx) => {
        return ctx.conversation.enter('default');
});

bot.start();

if you pass { maxMilliseconds: 0 } to waitFor(), it works

@gomez-git gomez-git changed the title Coversation doesn't end when maxMilliseconsToWait reaches timeout when use waitFor('message:text') Coversation doesn't end when maxMillisecondsToWait reaches timeout when use waitFor('message:text') Sep 26, 2023
@gomez-git
Copy link
Author

i think at this line missing default value for maxMilliseconds

const { otherwise, drop, maxMilliseconds } = toObj(opts);

       const { otherwise, drop, maxMilliseconds = this.timeout } = toObj(opts);

@github-project-automation github-project-automation bot moved this to To do in Coding Oct 2, 2023
@KnorpelSenf KnorpelSenf added the bug Something isn't working label Oct 2, 2023
@notvxn
Copy link

notvxn commented Apr 2, 2024

+1

@gomez-git gomez-git changed the title Coversation doesn't end when maxMillisecondsToWait reaches timeout when use waitFor('message:text') Conversation doesn't end when maxMillisecondsToWait reaches timeout when use waitFor('message:text') Apr 13, 2024
@KnorpelSenf KnorpelSenf added the v2 Needs to be fixed before v2 label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2 Needs to be fixed before v2
Projects
No open projects
Status: To do
Development

Successfully merging a pull request may close this issue.

3 participants