python-botogram/botogram

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

abhi3700 opened this issue · 2 comments

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

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

Ok thanks!