-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathkeyboards.py
74 lines (63 loc) · 1.76 KB
/
keyboards.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import datetime
import json
from typing import Any, Dict, List
show_events_buttons = [
[
{'text': 'Today', 'callback_data': 'Today'},
{'text': 'This week', 'callback_data': 'This week'}
]
]
new_event_buttons = [
[
{'text': 'Create ✅', 'callback_data': 'create'},
{'text': 'Cancel 🚫', 'callback_data': 'cancel'}
]
]
field_buttons = [
[
{'text': 'Restart 🚀', 'callback_data': 'restart'},
{'text': 'Cancel 🚫', 'callback_data': 'cancel'}
]
]
DATE_FORMAT = '%d %b %Y'
def get_this_week_buttons() -> List[List[Any]]:
today = datetime.datetime.today()
buttons = []
for day in range(1, 7):
day = today + datetime.timedelta(days=day)
buttons.append(day.strftime(DATE_FORMAT))
return [
[
{
'text': buttons[0],
'callback_data': buttons[0],
},
{
'text': buttons[1],
'callback_data': buttons[1],
},
{
'text': buttons[2],
'callback_data': buttons[2],
},
],
[
{
'text': buttons[3],
'callback_data': buttons[3],
},
{
'text': buttons[4],
'callback_data': buttons[4],
},
{
'text': buttons[5],
'callback_data': buttons[5],
},
],
]
def gen_inline_keyboard(buttons: List[List[Any]]) -> Dict[str, Any]:
return {'reply_markup': json.dumps({'inline_keyboard': buttons})}
show_events_kb = gen_inline_keyboard(show_events_buttons)
new_event_kb = gen_inline_keyboard(new_event_buttons)
field_kb = gen_inline_keyboard(field_buttons)