исправь некоторые участки кода import logging
import sqlite3
import telegram
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext

logging.basicConfig(level=logging.INFO)
bot = telegram.Bot(token='YOUR_BOT_TOKEN')
API_TOKEN = 'YOUR_API_TOKEN'

category_tables = {
    'Кроссовки': 'items',
    'Верхняя одежда': 'items1',
    'Аксессуары': 'items2',
}

def start(update: Update, context: CallbackContext):
    keyboard = [
        [InlineKeyboardButton(category, callback_data=category) for category in category_tables]
    ]
    reply_markup = InlineKeyboardMarkup(keyboard)
    if update.message:
        update.message.reply_text('Выберите категорию товара:', reply_markup=reply_markup)
    else:
        query = update.callback_query
        query.answer()
        query.edit_message_text('Выберите категорию товара:', reply_markup=reply_markup)

def category_handler(update: Update, context: CallbackContext):
    query = update.callback_query
    category = query.data
    table = category_tables[category]
    conn = sqlite3.connect('kross.db')
    c = conn.cursor()
    c.execute(f'SELECT name FROM {table}')
    items = c.fetchall()
    keyboard = [
        [InlineKeyboardButton(items[i][0], callback_data=f'{table}{i}') for i in range(min(4, len(items)))]
    ]
    if len(items) > 4:
        keyboard.append([
            InlineKeyboardButton('Вперед', callback_data=f'next{table}0_4')
        ])
    reply_markup = InlineKeyboardMarkup(keyboard)
    query.answer()
    query.edit_message_text(f'Выберите товар ({category}):', reply_markup=reply_markup)

def show_product(update: Update, context: CallbackContext):
    query = update.callback_query
    data = query.data.split(' ')
    table = data[0]
    index = int(data[1])
    conn = sqlite3.connect('kross.db')
    c = conn.cursor()
    c.execute(f'SELECT name, size, info, price, photo_link FROM {table}')
    items = c.fetchall()
    item = items[index]
    text = f'Название: {item[0]}\nРазмер: {item[1]}\nОписание: {item[2]}\nЦена: {item[3]}\nСсылка на фото: {item[4]}'
    keyboard = [
        [InlineKeyboardButton('Вернуться', callback_data=f'back_{table}')]
    ]
    reply_markup = InlineKeyboardMarkup(keyboard)
    query.answer()
    query.edit_message_text(text=text, reply_markup=reply_markup)

def change_page(update: Update, context: CallbackContext):
    query = update.callback_query
    data = query.data.split(' ')
    action = data[0]
    table = data[1]
    start_index = int(data[2])
    end_index = int(data[3])
    conn = sqlite3.connect('kross.db')
    c = conn.cursor()
    c.execute(f'SELECT name FROM {table}')
    items = c.fetchall()
    prev_start = max(0, start_index - 4)
    prev_end = start_index
    next_start = end_index
    next_end = min(end_index + 4, len(items))
    if action == 'next':
        start_index = next_start
        end_index = next_end
def show_product(update: Update, context: CallbackContext):
    query = update.callback_query
    data = query.data.split(‘‘)
    table = data[0]
    index = int(data[1])

    conn = sqlite3.connect(‘kross.db’)
    c = conn.cursor()
    c.execute(f’SELECT name, size, info, price, photo_link FROM {table}’)
    items = c.fetchall()
    item = items[index]

    text = f’Название: {item[0]}\nРазмер: {item[1]}\nОписание: {item[2]}\nЦена: {item[3]}\nСсылка на фото: {item[4]}‘

    keyboard = [
        [InlineKeyboardButton(‘Вернуться’, callback_data=f’back_{table}’)]
    ]
    reply_markup = InlineKeyboardMarkup(keyboard)
    query.answer()
    query.edit_message_text(text=text, reply_markup=reply_markup)
def back_button_handler(update: Update, context: CallbackContext):
    query = update.callback_query
    table = query.data.split(‘‘)[1]

    # отображаем клавиатуру выбора товара
    for category, tbl in category_tables.items():
        if tbl == table:
            query.data = category
            category_handler(update, context)
            break
def main():
    updater = Updater(API_TOKEN)

    dp = updater.dispatcher
    dp.add_handler(CommandHandler(‘start’, start))
    for tbl in category_tables.values():
        dp.add_handler(CallbackQueryHandler(show_product, pattern=f’^{tbl}\d+'))
    dp.add_handler(CallbackQueryHandler(change_page, pattern='^(prev|next)_[a-zA-Z0-9]+_(
updater.idle()
if name == 'main':
main()