-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathsimple_telethon.py
More file actions
34 lines (23 loc) · 923 Bytes
/
simple_telethon.py
File metadata and controls
34 lines (23 loc) · 923 Bytes
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
"""
Example using telethon.
"""
from telethon import TelegramClient, events
from telegram_bot_calendar import DetailedTelegramCalendar, LSTEP
api_id = 123456
api_hash = "1233456789"
bot_token = "token"
bot = TelegramClient("bot", api_id, api_hash)
@bot.on(events.NewMessage(pattern="/start"))
async def reply_handler(event):
calendar, step = DetailedTelegramCalendar(telethon=True).build()
await event.respond(f"Select {LSTEP[step]}", buttons=calendar)
@bot.on(events.CallbackQuery(pattern=DetailedTelegramCalendar.func(telethon=True)))
async def calendar_handler(event):
result, key, step = DetailedTelegramCalendar(telethon=True).process(event.data.decode("utf-8"))
if not result and key:
await event.edit(f"Select {LSTEP[step]}", buttons=key)
elif result:
await event.edit(f"You selected {result}")
bot.start(bot_token=bot_token)
with bot:
bot.run_until_disconnected()