в телеграм боте

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

import telebot

from telebot import types

from telebot_calendar import Calendar, CallbackData, RUSSIAN_LANGUAGE

import datetime


bot = telebot.TeleBot('1968025037:AAGWtP9pcuQ6tk0m9YD5_MBl845dMaMNbGw')
calendar = Calendar(language=RUSSIAN_LANGUAGE)
calendar_1 = CallbackData('calendar_1', 'action', 'year', 'month', 'day')
now = datetime.datetime.now()


@bot.message_handler(commands=['start'])
def welcome(message):
    # keyboard
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
    item1 = types.KeyboardButton("ЗАПИСАТЬСЯ")
    item2 = types.KeyboardButton("ОТМЕНА ЗАПИСИ")
    item3 = types.KeyboardButton("ДАТА")

    markup.add(item1,item2,item3)

    bot.send_message(message.chat.id, "Добрый день, {0.first_name}  {0.last_name}!\nВы хотите записаться на массаж, нажмите кнопку ЗАПИСАТЬСЯ.".format(message.from_user, bot.get_me()),
    parse_mode='html', reply_markup=markup)


@bot.message_handler(content_types=['text'])
def call(message):
    if message.text == 'ДАТА':
        bot.send_message(message.chat.id, 'Выберите дату', reply_markup=calendar.create_calendar(
            name=calendar_1.prefix,
            year=now.year,
            month=now.month)
            )

        if message.text == 'ЗАПИСАТЬСЯ':
            markup = types.InlineKeyboardMarkup(row_width=2)
            item1 = types.InlineKeyboardButton("11:00", callback_data='time')
            item2 = types.InlineKeyboardButton("12:00", callback_data='time1')
            item3 = types.InlineKeyboardButton("13:00", callback_data='time2')
            item4 = types.InlineKeyboardButton("14:00", callback_data='time3')
            item5 = types.InlineKeyboardButton("15:00", callback_data='time4')
            item6 = types.InlineKeyboardButton("16:00", callback_data='time5')
            item7 = types.InlineKeyboardButton("17:00", callback_data='time6')
            item8 = types.InlineKeyboardButton("18:00", callback_data='time7')
            item9 = types.InlineKeyboardButton("19:00", callback_data='time8')
            item10 = types.InlineKeyboardButton("20:00", callback_data='time9')
            item11 = types.InlineKeyboardButton("21:00", callback_data='time10')


            markup.add(item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11)

            bot.send_message(message.chat.id , 'Отлично {0.first_name},на какое время хотели бы записаться?  '.format(message.from_user, bot.get_me()),
                parse_mode='html', reply_markup=markup)
        elif message.text == "ОТМЕНА ЗАПИСИ":
            bot.send_message(message.chat.id, 'Очень жаль')

        else:
            bot.send_message(message.chat.id, 'НЕ ПРАВИЛЬНАЯ КОМАНДА')
            return


#@bot.callback_query_handler(func=lambda call: call.data.startswith(calendar_1.prefix))
#def callback_inline(call: types.CallbackQuery): 
#   name, action, year, month, day = call.data.split(calendar_1.sep)
#
#    if action == 'DAY':
#        bot.send_message(chat_id=call.from_user.id, text=f'Вы выбрали {date.strftime("%d.%m.%Y")}', reply_markup=types.ReplyKeyboardRemove())
#        
#    elif action == 'CANCEL':
#        bot.send_message(chat_id=call.from_user.id, text='Отмена', reply_markup=types.ReplyKeyboardRemove())       


@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    try:
        if call.message:
            if call.data == 'time':
                bot.send_message(call.message.chat.id, 'Вы записались на 11:00, будем ждать!' )
            elif call.data == 'time1':
                bot.send_message(call.message.chat.id, 'Вы записались на 12:00, будем ждать!')
            elif call.data == 'time2':
                bot.send_message(call.message.chat.id, 'Вы записались на 13:00, будем ждать!')
            elif call.data == 'time3':
                bot.send_message(call.message.chat.id, 'Вы записались на 14:00, будем ждать!')
            elif call.data == 'time4':
                bot.send_message(call.message.chat.id, 'Вы записались на 15:00, будем ждать!')
            elif call.data == 'time5':
                bot.send_message(call.message.chat.id, 'Вы записались на 16:00, будем ждать!')
            elif call.data == 'time6':
                bot.send_message(call.message.chat.id, 'Вы записались на 17:00, будем ждать!')
            elif call.data == 'time7':
                bot.send_message(call.message.chat.id, 'Вы записались на 18:00, будем ждать!')
            elif call.data == 'time8':
                bot.send_message(call.message.chat.id, 'Вы записались на 19:00, будем ждать!')
            elif call.data == 'time9':
                bot.send_message(call.message.chat.id, 'Вы записались на 20:00, будем ждать!')
            elif call.data == 'time10':
                bot.send_message(call.message.chat.id, 'Вы записались на 21:00, будем ждать!')

                bot.send_message(message.from_user, 'Вы записанны ')

            elif call.data == 'bad':

                bot.send_message(call.message.chat.id, 'Бывает ?')

            # remove inline buttons
            bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Поздравляю",reply_markup=None)
            
            # show alert
            bot.answer_callback_query(callback_query_id=call.id, show_alert=False,
                text="БУДЕМ РАДЫ ВАС ВИДИТЬ!")

    except Exception as e:
        print(repr(e))

# RUN
bot.polling(none_stop=True)

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