I am making a telegram bot api wrapper and was wondering how to get the user’s location. I have tried this:
def test(chat):
reply_markup = {
"chat_id" : chat,
"text": "your message",
"reply_markup":
{"keyboard":
[
[{"text": "Send Your Mobile", "request_contact": True}],
[{"text": "Send Your Location", "request_location": True}]
]
}
}
and:
def func():
keyboard = [{"text":"Hello", "request_location":True}]
reply_markup = {"keyboard":keyboard, "one_time_keyboard":True}
return json.dumps(reply_markup)
to make a thing to submit to my send_messages func which I got from: https://www.codementor.io/garethdwyer/building-a-telegram-bot-using-python-part-1-goi5fncay
How would I do that?
2
Answers
First, you can only use
request_location
in private chat, make sure it is not send to group.If succeeded, user will send location as message, just like sendLocation method, you need to handle new message to get location.
For python-telegram-bot users: