Как менять кнопки в Телеграм боте?

Как можно сделать так, чтобы если text == 'расписание', появлялись кнопки с днями недели?

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
MAIN_KEYBOARD = [['Расписание', 'Домашка']]
def text_action(update, context):
    text = update.message.text.lower()
    cid = update.effective_chat.id
    if text == 'расписание':
        pass```

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

Автор решения: Иван Борисов
def chunks(l, n):
    n = max(1, n)
    return list((l[i:i + n] for i in range(0, len(l), n)))


def create_markup(group_id, update):
    buttons = []

    if group_id == 0:
       buttons += ['кнопка1','кнопка2',...]
    elif group_id == 1:
       buttons += ['кнопка1','кнопка2',...]
    ...
    keyboard = [KeyboardButton(button) for button in buttons]
    if len(keyboard) > 3:
        keyboard = chunks(keyboard, 3)
    else:
        keyboard = [keyboard]
    markup = ReplyKeyboardMarkup(keyboard, resize_keyboard=True)
    return markup

def second_step(update, context):
    if text == '...':
            markup = create_markup(group_id=0, update=update)
            context.bot.send_message(chat_id=update.message.chat_id,
                                     text='...',
                                     reply_markup=markup)
    elif text == '...':
            markup = create_markup(group_id=1, update=update)
            context.bot.send_message(chat_id=update.message.chat_id,
                                     text='...',
                                     reply_markup=markup)
→ Ссылка