Untitled
unknown
plain_text
2 years ago
1.7 kB
5
Indexable
import telebot
import datetime
import telebot_calendar
bot = telebot.TeleBot('6930570585:AAEdmedLhpaQ_553gJ42spQael3vh9px_Is')
current_shown_dates = {}
calendar = telebot_calendar.Calendar()
@bot.message_handler(commands=['calendar'])
def get_calendar(message):
now = datetime.datetime.now() #Текущая дата
chat_id = message.chat.id
date = (now.year,now.month)
current_shown_dates[chat_id] = date #Сохраним текущую дату в словарь
markup = calendar.create_calendar(name='Календарь',
year=now.year,
month=now.month)
bot.send_message(message.chat.id, "Пожалйста, выберите дату", reply_markup=markup)
calendar_1 = telebot_calendar.CallbackData('Кадендарь', 'action', 'year', 'month', 'day')
@bot.callback_query_handler(func=lambda call: call.data.startswith('Календарь'))
def callback_inline(call: telebot.types.CallbackQuery):
name, action, year, month, day = call.data.split(calendar_1.sep)
date = calendar.calendar_query_handler(bot=bot, call=call, name=name,
action=action, year=year,
month=month, day=day)
bot.send_message(call.message.chat.id, str(date))
@bot.message_handler(commands=['time'])
def get_time(message):
bot.send_message(message.chat.id, 'Введите время в формате HH:MM')
bot.register_next_step_handler(message, process_time_step)
def process_time_step(message):
time = message.text
print(time)
bot.polling(non_stop=True)Editor is loading...
Leave a Comment