-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard.py
65 lines (45 loc) · 2.76 KB
/
keyboard.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
# -*- coding: utf-8 -*-
from config import *
from all_json_data import *
class Keyboard:
@staticmethod
def menu_keyboard(chat_id, _, msg_id=None):
markup = telebot.types.InlineKeyboardMarkup()
for lesson in all_lessons:
markup.add(telebot.types.InlineKeyboardButton(text=all_lessons[lesson]["text"], callback_data=lesson))
if msg_id:
Main.BOT.edit_message_text(chat_id=chat_id, message_id=msg_id, text="Меню", reply_markup=markup)
else:
Main.BOT.send_message(chat_id=chat_id, text="Меню", reply_markup=markup)
Main.USER_LIST[chat_id]["dir"] = "menu"
@staticmethod
def lesson_keyboard(chat_id, json_dir_name, msg_id):
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(text="⬅️ Назад", callback_data="menu"))
for example in all_lessons[json_dir_name]["more"]:
example_json = all_lessons[json_dir_name]["more"][example]
markup.add(telebot.types.InlineKeyboardButton(text=example_json["text"], callback_data=f"{json_dir_name}/{example}"))
Main.BOT.edit_message_text(chat_id=chat_id, message_id=msg_id, text=all_lessons[json_dir_name]["text"], reply_markup=markup)
Main.USER_LIST[chat_id]["dir"] = json_dir_name
@staticmethod
def rules_keyboard(chat_id, json_dir_name, msg_id):
if len(json_dir_name) == 1:
Keyboard.lesson_keyboard(chat_id, json_dir_name[0], msg_id)
return
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(text="⬅️ Назад", callback_data=json_dir_name[-2]))
for example in all_rules[json_dir_name[1]]["more"]:
example_json = all_rules[json_dir_name[1]]["more"][example]
markup.add(telebot.types.InlineKeyboardButton(text=example_json["text"], callback_data="/".join(json_dir_name)+"/"+example))
Main.BOT.edit_message_text(chat_id=chat_id, message_id=msg_id, text=all_rules[json_dir_name[1]]["text"], reply_markup=markup)
Main.USER_LIST[chat_id]["dir"] = "/".join(json_dir_name)
@staticmethod
def admin_keyboard(chat_id, _):
if not chat_id in Main.ADMINS:
return
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(text="⬅️ Назад", callback_data="menu"))
for command in admin_commands:
markup.add(telebot.types.InlineKeyboardButton(text=command, callback_data=f"admin/{command}"))
Main.BOT.send_message(chat_id=chat_id, text="Панель Администратора", reply_markup=markup)
Main.USER_LIST[chat_id]["dir"] = "admin"