-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyboards.py
More file actions
163 lines (133 loc) · 5.64 KB
/
keyboards.py
File metadata and controls
163 lines (133 loc) · 5.64 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
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
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.utils.keyboard import InlineKeyboardBuilder
from config import PLANS, is_admin
from languages import lang_manager
def get_text(key: str, **kwargs) -> str:
"""Get localized text"""
return lang_manager.get_text(key, **kwargs)
def get_main_menu_keyboard(user_id: int = None) -> InlineKeyboardMarkup:
"""Get main menu keyboard - different for admin vs normal users"""
builder = InlineKeyboardBuilder()
if is_admin(user_id):
# Admin gets full menu
# First row - Main actions
builder.row(
InlineKeyboardButton(text=get_text("btn_register_udid"), callback_data="register"),
InlineKeyboardButton(text=get_text("btn_search"), callback_data="search")
)
# Second row - Key and IPA management
builder.row(
InlineKeyboardButton(text=get_text("btn_use_key"), callback_data="use_key"),
InlineKeyboardButton(text=get_text("btn_manage_ipas"), callback_data="manage_ipas")
)
# Third row - Settings
builder.row(
InlineKeyboardButton(text=get_text("btn_settings"), callback_data="settings")
)
else:
# Normal users get limited menu - only Search and Use Key
builder.row(
InlineKeyboardButton(text=get_text("btn_search"), callback_data="search"),
InlineKeyboardButton(text=get_text("btn_use_key"), callback_data="use_key")
)
return builder.as_markup()
def get_plans_keyboard() -> InlineKeyboardMarkup:
"""Get plans selection keyboard"""
builder = InlineKeyboardBuilder()
for plan_id, description in PLANS.items():
builder.row(
InlineKeyboardButton(
text=description,
callback_data=f"plan_{plan_id}"
)
)
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="back_to_main")
)
return builder.as_markup()
def get_key_plans_keyboard() -> InlineKeyboardMarkup:
"""Get plans selection keyboard for key creation"""
builder = InlineKeyboardBuilder()
for plan_id, description in PLANS.items():
builder.row(
InlineKeyboardButton(
text=description,
callback_data=f"key_plan_{plan_id}"
)
)
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="settings")
)
return builder.as_markup()
def get_back_keyboard() -> InlineKeyboardMarkup:
"""Get back to main menu keyboard"""
builder = InlineKeyboardBuilder()
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="back_to_main")
)
return builder.as_markup()
def get_settings_keyboard() -> InlineKeyboardMarkup:
"""Get settings keyboard - horizontal layout"""
builder = InlineKeyboardBuilder()
# First row - API Key and Thumbnails
builder.row(
InlineKeyboardButton(text=get_text("btn_set_api_key"), callback_data="set_api_key"),
InlineKeyboardButton(text=get_text("btn_set_thumbnails"), callback_data="set_thumbnails")
)
# Second row - Create Keys
builder.row(
InlineKeyboardButton(text=get_text("btn_create_keys"), callback_data="create_keys")
)
# Third row - Back button
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="back_to_main")
)
return builder.as_markup()
def get_certificate_keyboard(udid: str, enabled: bool = True, status: str = "active", user_id: int = None) -> InlineKeyboardMarkup:
"""Get certificate management keyboard - different for admin vs normal users"""
builder = InlineKeyboardBuilder()
# Only admin gets toggle button
if is_admin(user_id):
toggle_emoji = "🟢" if enabled else "🔴"
toggle_text = f"{toggle_emoji} {'Enabled' if enabled else 'Disabled'}"
builder.row(
InlineKeyboardButton(text=toggle_text, callback_data=f"toggle_{udid}")
)
# Get Certificate button (only if enabled and active)
if enabled and status == "active":
builder.row(
InlineKeyboardButton(text=get_text("btn_get_certificate"), callback_data=f"download_cert_{udid}")
)
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="back_to_main")
)
return builder.as_markup()
def get_udid_input_keyboard() -> InlineKeyboardMarkup:
"""Get UDID input keyboard"""
builder = InlineKeyboardBuilder()
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="back_to_main")
)
return builder.as_markup()
def get_ipa_management_keyboard() -> InlineKeyboardMarkup:
"""Get IPA management keyboard"""
builder = InlineKeyboardBuilder()
builder.row(
InlineKeyboardButton(text=get_text("btn_upload_ipa"), callback_data="upload_ipa"),
InlineKeyboardButton(text=get_text("btn_list_ipas"), callback_data="list_ipas")
)
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="back_to_main")
)
return builder.as_markup()
def get_ipa_actions_keyboard(ipa_id: int) -> InlineKeyboardMarkup:
"""Get IPA actions keyboard"""
builder = InlineKeyboardBuilder()
builder.row(
InlineKeyboardButton(text=get_text("btn_get_install_link"), callback_data=f"ipa_link_{ipa_id}"),
InlineKeyboardButton(text=get_text("btn_delete"), callback_data=f"delete_ipa_{ipa_id}")
)
builder.row(
InlineKeyboardButton(text=get_text("btn_back"), callback_data="manage_ipas")
)
return builder.as_markup()