-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesign.py
More file actions
41 lines (35 loc) Β· 1.48 KB
/
Copy pathdesign.py
File metadata and controls
41 lines (35 loc) Β· 1.48 KB
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
from telebot import types
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
from credentials import bot
# Keywords
start_commands = ["/start", "/help", "/home"]
other_commands = ['/profile', '/aboutus', '/services', '/question']
menu_options = ['π Services', 'π About us', 'π©βπ« My profile', 'π My appointments']
menu_navigation = ['β¬
οΈ Back', 'β¬οΈ Home']
menu_change_profile = ['Change Phone Number', 'Change Full Name']
#---------------------BUTTONS LAYOUT DESIGN------------------
# Helper function for building a list of buttons in a grid
def build_menu(buttons, n_cols, header_buttons=None, footer_buttons=None):
menu = [buttons[i:i + n_cols] for i in range(0, len(buttons), n_cols)]
if header_buttons:
menu.insert(0, header_buttons)
if footer_buttons:
menu.append(footer_buttons)
return menu
# ----------KEYBOARD MENU----------
# Define custom keyboard
def keyboard(bttns=[], btn_back=True, btn_home=True, n_cols=3):
menu_keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
if not any(isinstance(i, list) for i in bttns):
bttns = [bttns]
for elem in bttns:
for i in range(0, len(elem), n_cols):
row = elem[i:i+n_cols]
menu_keyboard.add(*row)
footer = []
if btn_back:
footer.append(types.KeyboardButton(menu_navigation[0]))
if btn_home:
footer.append(types.KeyboardButton(menu_navigation[1]))
menu_keyboard.add(*footer)
return menu_keyboard