I'm working on a telegramm bot, and during one process, I get a JSON data consisting of several items with 2 fields, and I need to make so, that after pressing button, data converts in checkbox and user can choose, which item do they have, and then I need to process those chosen items to server via POST, but I'm stuck on converting data and showing it to the user. Data is stored in form of list, consisting of dictionary with fields "Name" and "ID"
I've tried this code, but it's 100% incorrect (since it not working), and I'm currently lacking knowledge on this matter, and having trouble with documentation. All this goes after pressing a button, sure that all correct and working before this part
res = requests.get(url=URL3, auth=auth, params={'login': user_login})
data = json.loads(res.content)
results = []
for item in data["Description"]:
result = {}
for key in ["Asset", "InventoryNumber"]:
result[key] = item[key]
results.append(result)
markup = types.InlineKeyboardMarkup(row_width=len(results))
for i, result in enumerate(results):
checkbox = types.InlineKeyboardButton(f"Name: {result['Asset']}\nID: {result['InventoryNumber']}",
callback_data=f"choice_{i}")
markup.add(checkbox)
msg = bot.send_message(call.message.chat.id, text='Choose needed assets', reply_markup=markup)
threading.Thread(target=func_del_mess, args=(msg.chat.id, msg.message_id,)).start()
Aucun commentaire:
Enregistrer un commentaire