Closed ProgrammingLife closed 1 year ago
The ctx.reply variants are used under the hood so I would expect to have the same behaviour as ctx.reply has. Can you verify that ctx.reply('something')
also ends up in the wrong thread?
When that's the case then it probably requires some grammY reply function improvements. But it also might be something else I am overlooking currently.
@EdJoPaTo, well, in my case ctx.reply() works fine and it replies exactly in the same thread_id because I specify it manually:
await ctx.reply( "msg", {
message_thread_id: 314,
} );
If I don't specify thread_id then it will send to default (or a first) thread_id, I believe. So it will send in the wrong thread_id if I don't specify it.
If I don't specify thread_id then it will send to default (or a first) thread_id, I believe. So it will send in the wrong thread_id if I don't specify it.
That was my question. As grammy-inline-menu does the same it ends up in the wrong thread. So its a bug in grammy: https://github.com/grammyjs/grammY/issues/352
As an ugly workaround you can use replyMenuToContext
. Normally menuMiddleware.replyToContext
simplifies the use of replyMenuToContext
. Using it manually allows you to add custom options via the other
argument.
Assuming you are using a single menuMiddleware with the default path (/
) you can use this:
bot.command("menu", ctx => {
// TODO: refactor to menuMiddleware.replyToContext(ctx) when grammy supports this
await replyMenuToContext(menu, ctx, '/', {
message_thread_id: ctx.message.message_thread_id,
});
});
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Describe your goal My code is:
Expected I call
/menu@mybot
from a supergroup's topic (some thread). So I expect the answer to get exactly in the same topic (or a thread) from which I called it. I see there is some "message_thread_id: 314," in the ctx object:ctx.message.message_thread_id
.How to specify it in the
replyToContext()
function? Since now it replies in wrong topic. It now replies to main topic of the supergroup but not to topic from where I call it.