DJTommek / better-location

Telegram bot for parsing and generating various of location formats.
https://t.me/BetterLocationBot
MIT License
7 stars 2 forks source link

Telegram channel - SneakyButtons for refreshable locations #134

Open DJTommek opened 11 months ago

DJTommek commented 11 months ago

Problem

When Sneaky buttons are enabled and refreshable location is processed, buttons can be added only on first edit (initial posting of message) because Telegram API method editMessageReplyMarkup is limited and can be used only for messages, that does not have any reply markup.

So this is would be best scenario:

  1. User shares live location
  2. Bot parse live location, append Sneaky buttons
  3. User updates his live location
  4. Bot notices that, update previously appended Sneaky buttons
  5. repeat 3 and 4 ...
  6. User stops sharing location / location expires
  7. Bot do final update of Sneaky buttons

Sadly it is not working. On step 4 message already has some reply markup and Telegram refuses to update this message again, thus request fails. Quote from documentation:

Updating messages

...

Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards.

Solution

Instead of posting services links into buttons (eg Google maps, mapy.cz, etc) there will be one specific link leading to BetterLocation web, that will have unique reference to that specific message and service, eg https://better-location.palider.cz/exit/<chat-message-reference>/mapycz.

When user clicks on this button, it will open this website, which will load the newest available location for given message and then redirect user to target service location (eg Google Maps, mapy.cz, etc).

[!IMPORTANT] Needs testing, if this solution is working even for mobile device (eg. Google maps should directly start navigation).