morethanwords / tweb

Telegram Web K, GPL v3
https://web.telegram.org/k/
GNU General Public License v3.0
1.75k stars 575 forks source link

[BUG] URL field of getBotCallbackAnswer is not processed #274

Open IRuslan opened 9 months ago

IRuslan commented 9 months ago

Describe the bug Based on official documentation of the keyboardButtonCallback, once a button is pressed by the user, the getBotCallbackAnswer method should be called. And there is a expected response of messages.botCallbackAnswer type. One of options is URL to the bot itself via URL field. However WebK version of Telegram client abandon this option while the same configuration works correctly on iOS and Desktop application.

To Reproduce Steps to reproduce the behavior (here we assume you have a own bot to interact with Telegram client):

  1. Use a bot to send inlineKeyboard with keyboardButtonCallback.
  2. Click on the button
  3. Bot receives callback query
  4. Bot sends a response in a form of messages.botCallbackAnswer with url and has_url fields accordingly to documentation
  5. Nothing happens on the client side

Expected behavior Telegram client should switch the user to specified URL once messages.botCallbackAnswer received.

Desktop (please complete the following information):

Additional context After quick overview, I have found a WebK source code responsible for processing of message field of the botCallbackAnswer. However there is nothing similar about url field.

Update: I also found this works in Web A, there is a piece of code where exactly url field processed.

morethanwords commented 9 months ago

This will be implemented together with games.

IRuslan commented 9 months ago

I wonder if there is any roadmap or issue to track?

Also, just a feeling that this is a part related to bots functionality and partially to games. While other features related to bots working maybe it makes sense to treat it separately from games (sounds like a separate huge feature request).

IRuslan commented 9 months ago

Just as idea what need to be changed on line 4291 of buubles.ts.

if(typeof callbackAnswer.message === 'string' && callbackAnswer.message.length) {
  toast(wrapRichText(callbackAnswer.message, {noLinks: true, noLinebreaks: true}));
} else if(typeof callbackAnswer.url === 'string' && callbackAnswer.url.length) {
  window.open(callbackAnswer.url);
}
morethanwords commented 9 months ago

Just as idea what need to be changed on line 4291 of buubles.ts.

It's not that simple, see this. What do you need it for?

IRuslan commented 9 months ago

It's not that simple, see this.

Agree. I just was not aware if any similar implementation already exists in WebK version.

What do you need it for?

I want to build the following workflow for the bot: 1) Bot send a message with inline button to Telegram group 2) Telegram user presses the button 3) Bot receives CallbackQuery event to provide initial processing 4) Then based on results bot sets up a callbackAnswer to redirect user to DM with bot (Telegram API allows only this kind of URLs for callbackAnswer) to continue interaction.