-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsimple_pytelegrambotapi.py
34 lines (25 loc) · 1005 Bytes
/
simple_pytelegrambotapi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
This is the simplest example of the calendar usage with pyTelegramBotAPI.
"""
from telebot import TeleBot
from telegram_bot_calendar import DetailedTelegramCalendar, LSTEP
bot = TeleBot("token")
@bot.message_handler(commands=['start'])
def start(m):
calendar, step = DetailedTelegramCalendar().build()
bot.send_message(m.chat.id,
f"Select {LSTEP[step]}",
reply_markup=calendar)
@bot.callback_query_handler(func=DetailedTelegramCalendar.func())
def cal(c):
result, key, step = DetailedTelegramCalendar().process(c.data)
if not result and key:
bot.edit_message_text(f"Select {LSTEP[step]}",
c.message.chat.id,
c.message.message_id,
reply_markup=key)
elif result:
bot.edit_message_text(f"You selected {result}",
c.message.chat.id,
c.message.message_id)
bot.polling()