type here
I have to send a list of name and status of along with buttons for each name.
I use the code below but whenever I click on button on message sent on telegram, It haver error name: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
keyboard = InlineKeyboardMarkup(row_width=4)
buttons = []
for index, row in lost_info.iterrows():
htmlstring += '...'
button_text = f"{row['pop_name']}"
button = InlineKeyboardButton(str(button_text), callback_data=str(button_text))
buttons.append(button)
if len(buttons) % 4 == 0: # Create a new row after every 4 buttons
keyboard.row(*buttons)
buttons = []
keyboard.row(*buttons)
bot.send_photo(chat_id, photo=open('page.png', 'rb'),reply_markup=keyboard)
def detail_message(content):
return f"You clicked {content}"
@bot.callback_query_handler(func=lambda call: True)
def callback(call):
content = call.data
bot.send_message(call.message.chat.id, text=detail_message(content))
ValueError Traceback (most recent call last)
~AppDataLocalTempipykernel_176402729174179.py in ?()
36
37 if lostnum1h > 0 :
38 print(lostnum1h)
39 # Proceed with polling if lostnum1h has data
—> 40 bot.polling()
41 else:
42 print(lostnum1h)
43 # Handle the case where there’s no data in lostnum1h (optional)
c:UsersYen Cassie FPTAppDataLocalProgramsPythonPython312Libsite-packagestelebot_init_.py in ?(self, non_stop, skip_pending, interval, timeout, long_polling_timeout, logger_level, allowed_updates, none_stop, restart_on_change, path_to_watch)
1174
1175 logger.info(‘Starting your bot with username: [@%s]’, self.user.username)
1176
1177 if self.threaded:
-> 1178 self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
1179 logger_level=logger_level, allowed_updates=allowed_updates)
1180 else:
1181 self.__non_threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
c:UsersYen Cassie FPTAppDataLocalProgramsPythonPython312Libsite-packagestelebot_init_.py in ?(self, non_stop, interval, timeout, long_polling_timeout, logger_level, allowed_updates)
1249 if not handled:
1250 polling_thread.stop()
…
1578 f”The truth value of a {type(self).name} is ambiguous. ”
1579 “Use a.empty, a.bool(), a.item(), a.any() or a.all().”
1580 )
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings…
How can I send a message with button and send back the information appropriate with that content?