-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboards.py
218 lines (202 loc) · 5.52 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from utils import chunks
CLEANUP = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🧹", callback_data="delete"),
],
]
)
OK_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Ok", callback_data="delete"),
],
]
)
POOL_CANCEL_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Cancel", callback_data="cancel:pool_menu"),
],
]
)
HOMEKEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Profile", callback_data="profile"),
InlineKeyboardButton("Check next lunch raffle", callback_data="schedule"),
],
]
)
OPTIONS_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Manage groups", callback_data="pool_menu"),
InlineKeyboardButton("Manage schedule", callback_data="schedule_menu"),
],
[
InlineKeyboardButton(
"Take a break", callback_data="account_menu:toggle:disqualified:True"
)
],
]
)
AWAY_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"Return from the break",
callback_data="account_menu:toggle:disqualified:False",
)
],
]
)
YES_NO_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Yes",
callback_data="True",
),
InlineKeyboardButton(
text="No",
callback_data="False",
),
]
]
)
SUBMIT_CANCEL_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Submit",
callback_data="True",
),
InlineKeyboardButton(
text="Cancel",
callback_data="False",
),
]
]
)
RETURN_TO_POOL_MENU_KEYBOARD = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Return to group menu",
callback_data="pool_menu",
),
],
]
)
def POOL_OPTIONS_KEYBOARD(has_pools: bool = False) -> InlineKeyboardMarkup:
keys = [
[
InlineKeyboardButton(
text="Browse public groups",
callback_data="pool_menu:browse",
)
],
[
InlineKeyboardButton(
text="Join a private group",
callback_data="pool_menu:join",
)
],
[
InlineKeyboardButton(
text="Create a new group",
callback_data="pool_menu:create",
)
],
[
InlineKeyboardButton(
text="Go back",
callback_data="profile",
)
],
]
if has_pools:
keys.insert(
0,
[
InlineKeyboardButton(
text="Browse your groups",
callback_data="pool_menu:manage",
)
],
)
return InlineKeyboardMarkup(keys)
def POOLS_KEYBOARD(extra: str = "", pools_shown: list = []) -> InlineKeyboardMarkup:
pool_buttons = list(
chunks(
[
InlineKeyboardButton(
f"View {pool['name']}",
callback_data=f"pool_menu:{pool['id']}:view{extra}",
)
for pool in pools_shown
],
3,
)
)
pool_buttons.append(
[
InlineKeyboardButton("Back", callback_data="pool_menu"),
]
)
return InlineKeyboardMarkup(pool_buttons)
def POOL_KEYBOARD(
pool: dict, is_member: bool, is_admin: bool, return_page: str | None = None
) -> InlineKeyboardMarkup:
return InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
f"{'Leave' if is_member else 'Join'} {pool['name']}",
callback_data=f"pool_menu:{pool['id']}:{'leave' if is_member else 'join'}",
)
],
[
InlineKeyboardButton(
f"Edit name",
callback_data=f"pool_menu:{pool['id']}:edit:name",
),
InlineKeyboardButton(
f"Edit description",
callback_data=f"pool_menu:{pool['id']}:edit:description",
),
InlineKeyboardButton(
f"Make {'private' if pool['public'] else 'public'}",
callback_data=f"pool_menu:{pool['id']}:toggle:public:{not pool['public']}",
),
]
if is_admin
else [],
[
InlineKeyboardButton(
f"🆘 Delete {pool['name']} 🆘",
callback_data=f"pool_menu:{pool['id']}:delete",
),
]
if is_admin
else [],
[
InlineKeyboardButton(
f"Set your schedule for {pool['name']}",
callback_data=f"pool_menu:{pool['id']}:schedule",
)
]
if is_member
else [],
[
InlineKeyboardButton(
"Back",
callback_data=return_page
if return_page is not None
else "pool_menu",
),
],
]
)