zanzara icon indicating copy to clipboard operation
zanzara copied to clipboard

Parameterized Callback Query Listeners

Open awohsen opened this issue 2 years ago • 2 comments

Hi, hope someone start and renew this project soon; btw it would be great if callback query data, be parametrized like texts as well.

Also right now for callback query data listeners we should provide an array, idk its for which case but providing single parametrized text would help a lot!

Thanks for improving this great async bot framework. 💗

awohsen avatar Apr 16 '22 23:04 awohsen

You can use the message_reply_to of the callback "only if your bot reply to and message".

example:

client --> /some_command product-3 bot --> reply to this command with the inline button. client --> click in the inline button. onCbQueryData listen that event then you get the text of the reply message $reply_to = $ctx->getCallbackQuery()->getMessage()->getReplyToMessage()->getMessage()->getText();.

devblack avatar May 15 '22 17:05 devblack

Yes, but it's only one aspect and way to do it despite the features that the listener provides.

Imagine an inline menu that has those products in and when the user chooses a product, the bot provides him another menu with inline buttons where each has its own functions related to the product and this menu is the same for all products the difference is the product code hidden in the callback query data example: buy-product3.

It's not impossible right now thanks to onCbQuery, but it catches all CbQueries...

awohsen avatar May 15 '22 22:05 awohsen