Добавление кнопок через pytelegrambotapi

Реализован парсер, требуется, чтобы отправлялась одно сообщение (записано в itog), затем появлялись кнопки "следующее", "закончить", и если закончить, то выходили из def callback_worker(call), если следующее, то цикл продолжается. Либо можно, чтобы бот отправлял сообщение с выбором, пользователь прописывал /next или /end и дальше обрабатывалось это сообщение

@bot.callback_query_handler(func=lambda call: True)
def callback_worker(call):
    if call.data == "Lawyer":
        # with open("vacations.txt", "r", encoding="UTF-16") as my_file:
        #     my_file.write(text)
        for n in range(10):
                text = parcerpython.parcer1(n)
                vac, salary, company, time, location, information, linksite = text[0], text[1], text[2], text[3], text[
                    4], \
                                                                              text[5], text[6]
                for j in range(len(vac)):
                    itog = ''
                    itog += 'Вакансия №' + str(j + 1) + '\n'
                    itog += vac[j] + '\n'
                    itog += salary[j] + '\n'
                    if len(company) == len(vac):
                        itog += company[j] + '\n'
                    itog += 'Время:' + str(time[j]) + '\n'
                    itog += location[j] + '\n'
                    itog += information[j] + '\n'
                    itog += 'https://www.superjob.ru' + linksite[j] + '\n'
                    # print(information)
                    bot.send_message(call.message.chat.id, itog)
                    bot.send_message(call.message.chat.id,"Если хотите продолжить, нажмите /next, если хотите закончить /end")

                    @bot.message_handler(content_types=['text'])
                    if message.text == "next":
                        continue

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