'How do i add handler to InlineKeyboardButton, so i can use data from message ubove it?
I gather data from Firebase Realtime Database and send it to Telegram bot as messages with buttons, that use varaiables from message used.
I want to catch the two variables longitude and latitude, then use it in the function lower, how can i do that?
@dp.message_handler(Text(equals='Get Maps'))
async def get_maps(message: types.Message):
await message.answer('Please wait a bit...')
data = collect_maps()
keyboard = types.InlineKeyboardMarkup()
key = types.InlineKeyboardButton('Get Location', callback_data='Get Location')
keyboard.add(key)
await message.answer('Your maps, that i collected:')
for index, item in enumerate(data):
card = f'{index+1}) {item.get("id")} - {item.get("name")}\n' \
f'Longitude: {item.get("longitude")}\n' \
f'Latitude: {item.get("latitude")}\n'
await message.answer(card, reply_markup=keyboard)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
