grammyjs / conversations

Conversational interfaces for grammY.
https://grammy.dev/plugins/conversations
MIT License
52 stars 17 forks source link

Crash only in 1 conversation #85

Closed dimashpt closed 1 year ago

dimashpt commented 1 year ago

I don’t know how to describe the issue, because it's confusing to me. I have 2 convos, it's all working good. But, when i add 1 more, enter the convo, and reply, i immediatelly get an error that says in session:

...
"error_code",
400,
"description",
"Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message",
"answerCallbackQuery",
...

Refer to my commit

I'm using TS with nodemon server, after the error, i didn’t get any response and the server says clean exit - waiting for changes before restart

you can also see my code here

Did i do any mistakes? Thanks

dimashpt commented 1 year ago

I finally found out. This is related with grammy-inline-menu. I have to do this:

const menu = new MenuTemplate<MainContext>(async (ctx) => {
  // I have to mock async function and return the string to make it works?
  const mock = () =>
    new Promise<string>((resolve) => {
      setTimeout(() => {
        resolve('Menu Presensi');
      }, 100);
    });
  const data = await mock();

  return data;
});

This is weird behaviour when i don't really need the promise. Any explanations? am i missing something?

KnorpelSenf commented 1 year ago

@EdJoPaTo do you know? It seems to be related to grammy-inline-menu?

EdJoPaTo commented 1 year ago

it seems very unlikely that this is the root cause as the body function of a MenuTemplate is just the sendMessage or editMessage text… using async/await will just delay the same method call to a later point…

The code is basically identical to this: const menu = new MenuTemplate<MainContext>('Menu Presensi');

Also the error is hidden via grammy-inline-menu itself when editing the menu so this error happens sometimes but is catched.

I am not sure how conversations work and they might be incompatible with the basic ideas of the grammy-inline-menu library… but in general it works with context filters.

Currently I dont have another idea where the root cause may be…

KnorpelSenf commented 1 year ago

I guess we cannot really do anything here. I will close this. @dimashpt feel free to reopen with a proper reproduction example of this problem if this is still an issue.