Answer the question
In order to leave comments, you need to log in
How to get location in Telegram bot from ReplyKeyboardMarkup?
I am writing a cart bot that would return the user's location when clicking ReplyKeyboardMarkup.
The code:
import telebot
from telebot import types
bot = telebot.TeleBot(API Token)
@bot.message_handler(commands=["start"])
def start (message):
#Клавиатура с кнопкой запроса локации
keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
button_geo = types.KeyboardButton(text="Отправить местоположение", request_location=True)
keyboard.add(button_geo)
bot.send_message(message.chat.id, "Поделись местоположением", reply_markup=keyboard)
#Получаю локацию
@bot.message_handler(content_types=['location'])
def location (message):
if message.location is not None:
print(message.location)
print(message)
bot.polling(none_stop = True)
input()
{'ok': True, 'result': []}
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