I
I
Ivanzolo20012021-11-14 10:15:56
Python
Ivanzolo2001, 2021-11-14 10:15:56

Why is the variable not added to callback_data (aiogram)?

There is a list with the names of the courses, I create an inline keyboard and go through all the elements of the list below. At the same time, I add the current element to the inline keyboard and also callback_data which is also equal to the current element. The problem is that this same calbback_data causes an error if you pass exactly the variable containing the current list element. If you write just some line, everything is OK, but I need a specific variable. How to be?

courses = ['first', 'second', 'и тд.']

courses_keyboard = InlineKeyboardMarkup()
for course in courses:
  courses_keyboard.add(InlineKeyboardButton(text=course, callback_data=course))


An error
raise err(cls.text or description)
aiogram.utils.exceptions.ButtonDataInvalid: Button_data_invalid


I think that there are limitations in bytes, is it possible to fix it somehow

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-14
@SoreMix

Most likely the limit has been exceeded. 1-64 characters should be

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question