EdJoPaTo / grammy-inline-menu

Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.
MIT License
357 stars 44 forks source link

How can I resubmit the menu after a message from the bot to the user #69

Closed maslopop closed 4 years ago

maslopop commented 4 years ago

Ciao, I have a need that is important to me; it happens that the bot replies the user with a message or an image as in the case of the screenshoot, I would like to redesign the menu after the message so that it appears again at the bottom and does not go up in the chat, as happens when a user answers a question.

Annotazione 2020-03-29 112434 new

I thank you for your quick answers .. Massimo

EdJoPaTo commented 4 years ago

The idea of inline buttons below a message is to stick to their context in the chat history. So basically not jumping around. I see it being useful but the current approach of the library wasn't built with that in mind.

Maybe the screenshot in your case is relevant for the current menu? Then maybe setting it as photo might be useful. Check the Readme for more details about how to use it. Its also in the example if you want to see it in action.

const menu = new TelegrafInlineMenu('Awesome text', {
  photo: currentAwesomeScreenshot())
}
maslopop commented 4 years ago

Wow, I always discover new things on this library. I didn't explain myself well, and for this I apologize for my poor English ... I would need replyWithphoto not to make the menu go above the photo, I would like to be able to position it again down in the chat ... in the bottom it is possible in some way ?

Thank you very much

Massimo

EdJoPaTo commented 4 years ago

The library wasnt built with an idea like that in mind. Thats why I suggested something different which might also work. ;)

Maybe something using replyMenuMiddleware.setSpecific combined with ctx.delete might work.

const menu = new TelegrafInlineMenu(…)
const replyMenuMiddleware = menu.replyMenuMiddleware()
menu.simpleButton(…, …, {
  doFunc: async ctx => {
    await replyMenuMiddleware.setSpecfic(ctx, 'actionCode')
    await ctx.deleteMessage()
  }
})

Hope it helps :)

maslopop commented 4 years ago

Yes i like it ...

fedeltà.submenu(carta_fidelity_foto, 'bcar2', new TelegrafInlineMenu('', { photo: (ctx) => { var card = dati_fid(ctx).fidelity var fcart = path.resolve(__dirname + it.pathcarte, card + '.png') if ((fs.existsSync(fcart))) { return { source: fs.readFileSync(fcart), filename: 'fidelity card ' + card } } } , hide: (ctx) => { return (dati_fid(ctx).fidelity == '') } }))