N
N
Nodir Malikov2020-05-09 09:02:59
Python
Nodir Malikov, 2020-05-09 09:02:59

How to send information not in separate messages, but in one message in the Telegram bot?

I have a dictionary handler that sends the names of the nearest places from a dictionary based on the user's location.

def uz_shop_view(message: telebot.types.Message) -> None:
  if message.location is not None:
    lon: float = message.location.longitude
    lat: float = message.location.latitude

    distance: List[...] = []
    for loc in STORES:
      result: float = geodesic(
      (loc['lons'], loc['lats']), (lon, lat)).meters
      distance.append(result)
      counter = len(distance)
    while counter > 0:
      i = distance.index(min(distance))
      print(i)
      distance[i] = 10 ** 100
      counter -= 1
      bot.send_message(message.chat.id, f' ' + '<b>'+STORES[i]['title']+'</b>' + '\n\n' + '<i>'+STORES[i]['address']+'</i>', parse_mode='html')


But each place is sent in separate messages. How to make them come in one message?

libraries: telebot, geopy

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alan Gibizov, 2020-05-09
@phaggi

I already said in the last question how to do it. You don't want to have everything done for you, do you?

N
nzarchii60, 2020-05-09
@nzarchii60

If the dictionary contains a list of the form

arr = ['one', 'two',  'tree']
print(arr) # Выведит весь словарь
['one', 'two',  'tree']
print(arr[0]) # первое значения словаря.
'one'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question