Answer the question
In order to leave comments, you need to log in
How to send locations to a user in telegram bot (python)?
I want to make a bot for Telegram (in Python), which will send the user certain places on the map that are closest to him. I'm attaching examples.
I'm completely new to Python, I made the base and buttons for all sorts of tutorials. Stuck on requesting location from user. The Telegram API says that this is done through request_location = True. But I don't understand where to put it. Therefore, question # 1: Do each button on the keyboard separately and assign request_location = True, or is there an option to assign this parameter to all buttons at once?
And question # 2: further it is not at all clear how to determine the radius and send places from the map? I don’t have to write the whole code, at least just tell me how to google it? And then, according to my requests, nothing sensible is found.
Examples of what a bot looks like
code
import telebot
bot = telebot.TeleBot('token')
@bot.message_handler(commands=['start'])
def start_message(message):
user_markup = telebot.types.ReplyKeyboardMarkup
user_markup.row('Gas stations', 'Pharmacy' )
user_markup.row('Products')
bot.send_message(message.chat.id, 'Hi, what are you looking for?', reply_markup=user_markup) #more
problems
@bot.message_handler(content_types=['text'])
def handle_text (message):
if message.text == 'Gas stations':
bot.send_location(message.from_user.id, 59.938924, 30.315311) #just a point on the map
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question