Skip to content

[BUG] Always asking the question when entering the chat #4

Open
@jlanza

Description

@jlanza

Following the conversation on issue #119 in telegraf-inline-menu I have used stalessquestion to get input from a user on a menu button click.
The problem that answering or not the question, every time the user exits (not leave) the chat, and go back to it, the question is displayed. I don't know why. I think it is a kind of bug or maybe a misunderstanding on the way to use the library.

Any help is welcomed.

const menu = new MenuTemplate<TelegrafContext>(() => 'Main Menu\n' + new Date().toISOString())

const menuTemplate = new MenuTemplate<TelegrafContext>(ctx => `Menu Template for ${ctx.match![1]}`)
const statelessQuestion = new TelegrafStatelessQuestion('stateless', async (ctx) => {
  await replyMenuToContext(WHAT_DO_IH_AVE_TO_PUT_HERE, ctx, menuPath);
});

bot.use(referralQuestion.middleware());
menuTemplate.interact('Default', 'default', {
  do: async (ctx, path) => {
    statelessQuestion.replyWithMarkdown(ctx, 
      'Please enter the new text for ' + ctx.match![1] + '.[ ](http://t.me/#menupath' 
      + path //ctx.match![0] 
      + ')');
    return true;
  }
});

const subMenu = new MenuTemplate<TelegrafContext>('Submenu')
subMenu.chooseIntoSubmenu('items', ['item1', 'item2'], menuTemplate, {columns: 1});

menu.submenu('Submenu', 'submenu', subMenu);
const menuMiddleware = new MenuMiddleware<TelegrafContext>('/', menu);
bot.use(menuMiddleware.middleware());

bot.command('openmenu', async (ctx) => menuMiddleware.replyToContext(ctx));

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot-api-limitationAlthough we'd like to, we cannot fix this as the Bot API does not support it for some reason

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions