В чём причина ошибки TypeError: 'int' object is not subscriptable?

@bot.callback_query_handler(func=lambda call: True)
def callback_query(call):
    cl = call.date.split('_')
    global count
    global page

    if cl[0] == 'unseen':
        bot.delete_message(call.message.chat.id, call.message.message_id)
    elif cl[0] == 'next-page':
        if page < count:
            page = page + 1
            markup = InlineKeyboardMarkup()
            markup.add(InlineKeyboardButton(text='Скрыть', callback_data='unseen'))
            markup.add(InlineKeyboardButton(text=f'<--- Назад', callback_data=f'back-page'),
                       InlineKeyboardButton(text=f'{page}/{count}', callback_data=f' '),
                       InlineKeyboardButton(text=f'Вперёд --->', callback_data=f'next-page'))
            bot.edit_message_text(f'Страница {page} из {count}', reply_markup=markup, chat_id=call.message.chat.id,
                                  message_id=call.message.message_id)

выдаёт ошибку:

File "C:\Users\USER\pythonProject3\bot1\mybot1.py", line 48, in callback_query if cl[0] == 'unseen':
~~^^^
TypeError: 'int' object is not subscriptable


Ответы (1 шт):

Автор решения: Nick

ты пытаешься сплитовать дату отправки сообщения, Вот структура json ответа бота:

{
 "update_id": 936316894,
 "message": {
  "message_id": 1683709,
  "from": {
   "id": ***,
   "is_bot": false,
   "first_name": "***",
   "username": "***",
   "language_code": "ru"
  },
  "chat": {
   "id": ***,
   "first_name": "***",
   "username": "***",
   "type": "private"
  },
  "date": 1715065696,
  "text": "123"
 }
}

Тебе нужно исправить cl = call.date.split('_') на cl = call.data.split('_')

→ Ссылка