Помогите с python, telebot

Кароче сделал бота что то типа предложки, нажимаю по кнопкам и ничего просто не просиходит, вот код:

 
# id группы 
group_id = ID
 
@bot.message_handler(content_types=['photo']) 
def handle_photo(message): 
    keyboard = types.InlineKeyboardMarkup() 
    keyboard.add(types.InlineKeyboardButton('Публично', callback_data='public')) 
    keyboard.add(types.InlineKeyboardButton('Анонимно', callback_data='anonymous')) 
    msg = bot.send_message(message.chat.id, "Прислать анонимно или публично?", 
                     reply_markup=keyboard) 
    bot.register_next_step_handler(msg, process_privacy) 
 
def process_privacy(message): 
    user_id = message.from_user.id 
    photo_id = message.photo[-1].file_id 
    if message.text == 'Публично': 
        user_name = message.from_user.username if message.from_user.username else message.from_user.first_name 
        caption = f"Фото от пользователя {user_name}" 
    else: 
        caption = "Анонимное фото" 
    bot.send_photo(group_id, photo_id, caption) 
    keyboard = types.InlineKeyboardMarkup() 
    keyboard.add(types.InlineKeyboardButton('Одобрить', callback_data='approve')) 
    keyboard.add(types.InlineKeyboardButton('Не одобрять', callback_data='reject')) 
    bot.send_message(group_id, "Одобрить фото?", reply_markup=keyboard) 
 
@bot.callback_query_handler(func=lambda call: True) 
def callback_query(call): 
    if call.data == 'approve': 
        bot.send_message(call.from_user.id, "Ваша фотка одобрена") 
    elif call.data == 'reject': 
        bot.send_message(call.from_user.id, "Ваша фотка не одобрена")```

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

Автор решения: Gleb 4y4enski

Ты в handle_photo присвоил кнопкам кб который не прописан в callback_query()

# id группы 
group_id = ID
 
@bot.message_handler(content_types=['photo']) 
def handle_photo(message): 
    keyboard = types.InlineKeyboardMarkup() 
    keyboard.add(types.InlineKeyboardButton('Публично', callback_data='public')) 
    keyboard.add(types.InlineKeyboardButton('Анонимно', callback_data='anonymous')) 
    msg = bot.send_message(message.chat.id, "Прислать анонимно или публично?", 
                     reply_markup=keyboard) 
    bot.register_next_step_handler(msg, process_privacy) 
 
def process_privacy(message): 
    user_id = message.from_user.id 
    photo_id = message.photo[-1].file_id 
    if message.text == 'Публично': 
        user_name = message.from_user.username if message.from_user.username else message.from_user.first_name 
        caption = f"Фото от пользователя {user_name}" 
    else: 
        caption = "Анонимное фото" 
    bot.send_photo(group_id, photo_id, caption) 
    keyboard = types.InlineKeyboardMarkup() 
    keyboard.add(types.InlineKeyboardButton('Одобрить', callback_data='approve')) 
    keyboard.add(types.InlineKeyboardButton('Не одобрять', callback_data='reject')) 
    bot.send_message(group_id, "Одобрить фото?", reply_markup=keyboard) 
 
@bot.callback_query_handler(func=lambda call: True) 
def callback_query(call): 
    if call.data == 'approve': 
        bot.send_message(call.from_user.id, "Ваша фотка одобрена") 
    elif call.data == 'reject': 
        bot.send_message(call.from_user.id, "Ваша фотка не одобрена")
    
    # Новое кб
    elif call.data == 'public': 
        bot.send_message(call.from_user.id, "Публично") 
    elif call.data == 'anonymous': 
        bot.send_message(call.from_user.id, "Анонимно")

→ Ссылка