understanding commited on
Commit
7ec2e33
Β·
verified Β·
1 Parent(s): 55a717b

Update bot/ui/keyboards.py

Browse files
Files changed (1) hide show
  1. bot/ui/keyboards.py +40 -19
bot/ui/keyboards.py CHANGED
@@ -2,39 +2,60 @@
2
  from hydrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
3
  from bot.ui.callbacks import (
4
  make,
5
- AUTH_JSON, AUTH_CI, CANCEL,
6
- MENU_HELP, MENU_AUTH, MENU_PROFILES, MENU_SPEEDTEST
 
7
  )
8
 
9
- def profiles_keyboard(profiles: list[dict]) -> InlineKeyboardMarkup:
10
- rows = []
11
- for p in profiles:
12
- pid = p["profile_id"]
13
- label = p.get("label") or pid[:6]
14
- rows.append([InlineKeyboardButton(f"🟒 Set current: {label}", callback_data=f"setdef:{pid}")])
15
- if not rows:
16
- rows = [[InlineKeyboardButton("No profiles", callback_data="noop")]]
17
- return InlineKeyboardMarkup(rows)
 
 
 
 
18
 
19
  def auth_menu_keyboard() -> InlineKeyboardMarkup:
20
  return InlineKeyboardMarkup(
21
  [
22
- [InlineKeyboardButton("πŸ“„ Paste client JSON", callback_data=make(AUTH_JSON))],
23
- [InlineKeyboardButton("πŸ”‘ Enter Client ID & Secret", callback_data=make(AUTH_CI))],
24
- [InlineKeyboardButton("❌ Cancel", callback_data=make(CANCEL))],
25
  ]
26
  )
27
 
28
- def main_menu_keyboard() -> InlineKeyboardMarkup:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  return InlineKeyboardMarkup(
30
  [
 
31
  [
32
- InlineKeyboardButton("πŸ” Add Profile", callback_data=make(MENU_AUTH)),
33
- InlineKeyboardButton("πŸ‘€ Profiles", callback_data=make(MENU_PROFILES)),
34
  ],
35
  [
36
- InlineKeyboardButton("⚑ Speedtest", callback_data=make(MENU_SPEEDTEST)),
37
- InlineKeyboardButton("❓ Help", callback_data=make(MENU_HELP)),
38
  ],
39
  ]
40
  )
 
2
  from hydrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
3
  from bot.ui.callbacks import (
4
  make,
5
+ AUTH_JSON, AUTH_CI, CANCEL, BACK,
6
+ MENU_HELP, MENU_AUTH, MENU_PROFILES, MENU_SPEEDTEST,
7
+ UP_GO, UP_EDIT, UP_PRIV, UP_CANCEL
8
  )
9
 
10
+ def main_menu_keyboard() -> InlineKeyboardMarkup:
11
+ return InlineKeyboardMarkup(
12
+ [
13
+ [
14
+ InlineKeyboardButton("πŸ” Add Profile", callback_data=make(MENU_AUTH)),
15
+ InlineKeyboardButton("πŸ‘€ Profiles", callback_data=make(MENU_PROFILES)),
16
+ ],
17
+ [
18
+ InlineKeyboardButton("⚑ Speedtest", callback_data=make(MENU_SPEEDTEST)),
19
+ InlineKeyboardButton("❓ Help", callback_data=make(MENU_HELP)),
20
+ ],
21
+ ]
22
+ )
23
 
24
  def auth_menu_keyboard() -> InlineKeyboardMarkup:
25
  return InlineKeyboardMarkup(
26
  [
27
+ [InlineKeyboardButton("πŸ“„ Send .json file / Paste JSON", callback_data=make(AUTH_JSON))],
28
+ [InlineKeyboardButton("πŸ”‘ Send Client ID + Secret", callback_data=make(AUTH_CI))],
29
+ [InlineKeyboardButton("⬅️ Back", callback_data=make(BACK))],
30
  ]
31
  )
32
 
33
+ def profiles_keyboard(profiles: list[dict]) -> InlineKeyboardMarkup:
34
+ rows = []
35
+ for i, p in enumerate(profiles, start=1):
36
+ pid = p.get("profile_id") or ""
37
+ ch = (p.get("channel_title") or p.get("label") or "Profile").strip()
38
+ btn = InlineKeyboardButton(f"🟒 Set current: [{i}] {ch}", callback_data=f"setdef:{pid}")
39
+ rows.append([btn])
40
+
41
+ rows.append([InlineKeyboardButton("⬅️ Back", callback_data=make(BACK))])
42
+ return InlineKeyboardMarkup(rows)
43
+
44
+ def upload_confirm_keyboard(privacy: str) -> InlineKeyboardMarkup:
45
+ priv_label = {"private": "πŸ”’ Private", "unlisted": "πŸ”— Unlisted", "public": "🌍 Public"}.get(
46
+ (privacy or "private").lower(),
47
+ "πŸ”’ Private"
48
+ )
49
  return InlineKeyboardMarkup(
50
  [
51
+ [InlineKeyboardButton("βœ… Upload", callback_data=make(UP_GO))],
52
  [
53
+ InlineKeyboardButton("✏️ Edit title/desc", callback_data=make(UP_EDIT)),
54
+ InlineKeyboardButton(priv_label, callback_data=make(UP_PRIV)),
55
  ],
56
  [
57
+ InlineKeyboardButton("❌ Cancel", callback_data=make(UP_CANCEL)),
58
+ InlineKeyboardButton("⬅️ Back", callback_data=make(BACK)),
59
  ],
60
  ]
61
  )