python-botogram / botogram

Just focus on your bots.
https://botogram.dev
MIT License
123 stars 27 forks source link

Get User's Geo-based location in a chat with Telegram Bot #138

Closed abhi3700 closed 5 years ago

abhi3700 commented 5 years ago

I am using this in a callback

import botogram

@bot.command("sendinfo")
def sendinfo_command(chat, message, args):
    """User has to click a button for giving information - Username, Datetime, Location"""
    btns = botogram.Buttons()

    btns[0].callback("Username", "username")     # button - Username
    btns[1].callback("Location", "location")     # button - Location

    chat.send("Please, select one of the buttons popping below.", attach= btns)

@bot.callback("location")
def location_callback(query, chat, message):
    loc = query.sender.location
    lat = loc.latitude
    lng = loc.longitude
    chat.send(str(lat) + " & " + str(lng))      # test
    query.notify("{latitude} & {longitude} saved.".format(latitude=lat, longitude=lng))

if __name__ == "__main__":
    bot.run()

When I am pressing location button, then there is no message (i.e. location i.e. lat, lng) sent from Bot in the chat.

telegram

Can anyone (@MarcoBuster) please help me with this? I followed the similar technique for callback from my previous issue

MarcoBuster commented 5 years ago

@abhi3700 You can't get the user's location from a callback query. The user must send its location via the attachments menu.

abhi3700 commented 5 years ago

Ok thanks!