Вылезает ошибка Error code: 400. Description: Bad Request: BUTTON_DATA_INVALID на telebot, python
Нужна помощь срочно!
У меня выходит такая ошибка:
2024-06-16 10:31:27,472 (__init__.py:1221 MainThread) ERROR - TeleBot: "Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: BUTTON_DATA_INVALID"
2024-06-16 10:31:27,473 (__init__.py:1223 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/__init__.py", line 1215, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/util.py", line 150, in raise_exceptions
raise self.exception_info
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/util.py", line 93, in run
task(*args, **kwargs)
File "/home/runner/IaandmalODIoZhKA/main.py", line 237, in chooseTopicPost
featurePoint([str(rdb.users.get_id(message.chat.id)), str(max(rdb.timeData.getFor_real_id(message.chat.id)["ids"]))], topic, dataPost, 0)
File "/home/runner/IaandmalODIoZhKA/main.py", line 270, in featurePoint
bot.send_message(
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/__init__.py", line 1755, in send_message
apihelper.send_message(
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/apihelper.py", line 273, in send_message
return _make_request(token, method_url, params=payload, method='post')
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/apihelper.py", line 168, in _make_request
json_result = _check_result(method_name, result)
File "/home/runner/IaandmalODIoZhKA/.pythonlibs/lib/python3.10/site-packages/telebot/apihelper.py", line 195, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: BUTTON_DATA_INVALID
"
полный код на replit
часть кода:
if step==1:
bot.delete_message(message.chat.id, message.message_id-1)
dataPost["Description"] = str(message.text)
db["timeData"][str(rdb.users.get_id(message.chat.id))]["ids"].append(max(db["timeData"][str(rdb.users.get_id(message.chat.id))]["ids"])+1)
db["timeData"][str(rdb.users.get_id(message.chat.id))][str(max(db["timeData"][str(rdb.users.get_id(message.chat.id))]["ids"]))]={"message":message}
featurePoint([str(rdb.users.get_id(message.chat.id)), str(max(rdb.timeData.getFor_real_id(message.chat.id)["ids"]))], topic, dataPost, 0)
def touchData(Data, message, topic, dataPost):
print("touchData", '=', Data)
#return ">:("
db["timeData"][str(rdb.users.get_id(message.chat.id))]["ids"].append(max(db["timeData"][str(rdb.users.get_id(message.chat.id))]["ids"])+1)
db["timeData"][str(rdb.users.get_id(message.chat.id))][str(max(db["timeData"][str(rdb.users.get_id(message.chat.id))]["ids"]))]={"message":message}
r = '{"message":'+str([str(rdb.users.get_id(message.chat.id)), str(max(rdb.timeData.getFor_real_id(message.chat.id)["ids"]))])+', "topic":'+str(topic)+', "dataPost":'+str(dataPost)+', "data":'+str(Data)+'}'
return r
def featurePoint(message, topic, dataPost, point=0):
message = rdb.timeData.getFor_id(message[0])[message[1]]["message"]
if topic == 1:
if point==0:
genderKey = InlineKeyboardMarkup()
d = {
"message":message,
"topic":topic,
"dataPost":dataPost
}
print(
touchData("boy", message, topic, dataPost),
"=",
type(touchData("boy", message, topic, dataPost)))
genderKey.add(
InlineKeyboardButton("Мальчик",
callback_data=base64.b64encode(zlib.compress((touchData("boy", message, topic, dataPost)).encode("utf-8"))).decode('utf-8')
),
InlineKeyboardButton("Девочка",
callback_data=base64.b64encode(zlib.compress((touchData("girl", message, topic, dataPost)).encode("utf-8"))).decode('utf-8')
)
)
bot.send_message(
message.chat.id,
"Одежда для девочки или мальчика? :",
reply_markup=genderKey
)