There is a bot that processes the Location request from the user. If a server receives a message of this type, the bot can return the distance between the coordinates that came from the user and a certain point on the map ( точка_А ).
Expanding functionality: the bot can return the distance to точка_B or точка_А . Question: how to distinguish the server, the distance to A or B user wants?

I mean that attaching geolocation to a message, you can not add text or media to this message. Clean location and all. If you could send a message that contained two types: Location and Text , it would be much easier - just add the line точка_А to geolocation and that's it.

Can it be done in the following way?

  • msg_1 : the user sends a message of type Text : "локация" ;
  • msg_2 : the bot returns two buttons: точка_А and точка_B ;
  • msg_3 : the user selects the desired button;
  • msg_4 : bot returns: "отправь свое местонахождение" ;
  • msg_5 : the user is sending the Location ;
  • the server counts the distance;
  • msg_6 : the bot returns the distance.

The next question is: how to get the data msg_3 at the time of the calculation of the distance using Webhook ?

    1 answer 1

    Use the InlineKeyboardButton (built-in buttons) in the msg_2 stage with the corresponding callback_data , for example, " point_A " and " point_B ". Then check the incoming Update objects for correspondence to the CallbackQuery type and if this is it - then look at the contents of the data field, and determine which button was pressed and which particular point the user selected.

    • And how at the msg_6 stage msg_6 bot get callback_data from the msg_3 stage? - Tarasovych
    • one
      @Tarasovich why at the stage msg_6 ? Received callback_data - go to step msg_4 - Anatol
    • as far as I understand, after checking callback_data you can only display an alert using the answerCallbackQuery method, this is what I tried to do: pastebin.com/x7c6XJ1z - Tarasovych
    • one
      @Tarasovych strange that this logic does not work for you. Or figured out already? - Anatol
    • did not understand (After InlineKeyboardMarkup it was possible to call only answerCallbackQuery - Tarasovych