understanding commited on
Commit
42291ba
Β·
verified Β·
1 Parent(s): fd8a4bd

Update bot/ui/keyboards.py

Browse files
Files changed (1) hide show
  1. bot/ui/keyboards.py +31 -14
bot/ui/keyboards.py CHANGED
@@ -38,6 +38,15 @@ def auth_menu_keyboard() -> InlineKeyboardMarkup:
38
 
39
 
40
  def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> InlineKeyboardMarkup:
 
 
 
 
 
 
 
 
 
41
  rows: list[list[InlineKeyboardButton]] = []
42
 
43
  default_profile_id = str(default_profile_id or "")
@@ -56,17 +65,19 @@ def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> Inl
56
  status = "βœ…" if is_connected else ("πŸ”‘" if not has_refresh else "⚠️")
57
  title = f"{prefix}{status} [{i}] {label}"[:50]
58
 
59
- rows.append([InlineKeyboardButton(title, callback_data=make("noop", pid[:8]))])
 
60
 
 
61
  btns: list[InlineKeyboardButton] = []
62
  if pid:
63
  btns.append(InlineKeyboardButton("βœ… Set default", callback_data=make("pdef", pid)))
64
  btns.append(InlineKeyboardButton("πŸ”— Login", callback_data=make("plog", pid)))
65
  btns.append(InlineKeyboardButton("πŸ—‘ Delete", callback_data=make("pdel", pid)))
66
-
67
  if btns:
68
  rows.append(btns)
69
 
 
70
  if last_error:
71
  rows.append([InlineKeyboardButton(f"⚠️ {last_error[:48]}", callback_data=make("noop", "err"))])
72
 
@@ -74,23 +85,12 @@ def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> Inl
74
  return InlineKeyboardMarkup(rows)
75
 
76
 
77
- def upload_confirm_keyboard(privacy: str, title_mode: str = "caption") -> InlineKeyboardMarkup:
78
  priv_label = {"private": "πŸ”’ Private", "unlisted": "πŸ”— Unlisted", "public": "🌍 Public"}.get(
79
  (privacy or "private").lower(), "πŸ”’ Private"
80
  )
81
-
82
- tm = (title_mode or "").lower().strip()
83
- b1 = "βœ… Filename" if tm == "filename" else "Filename"
84
- b2 = "βœ… Caption" if tm == "caption" else "Caption"
85
- b3 = "βœ… Custom" if tm == "custom" else "Custom"
86
-
87
  return InlineKeyboardMarkup(
88
  [
89
- [
90
- InlineKeyboardButton(b1, callback_data=make(NAME_ORIGINAL)),
91
- InlineKeyboardButton(b2, callback_data=make(NAME_CAPTION)),
92
- InlineKeyboardButton(b3, callback_data=make(NAME_CUSTOM)),
93
- ],
94
  [InlineKeyboardButton("βœ… Upload", callback_data=make(UP_GO))],
95
  [
96
  InlineKeyboardButton("✏️ Edit title/desc", callback_data=make(UP_EDIT)),
@@ -101,4 +101,21 @@ def upload_confirm_keyboard(privacy: str, title_mode: str = "caption") -> Inline
101
  InlineKeyboardButton("⬅️ Back", callback_data=make(BACK)),
102
  ],
103
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  )
 
38
 
39
 
40
  def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> InlineKeyboardMarkup:
41
+ """
42
+ Must match handlers.py:
43
+ profiles_keyboard(profiles, default_id)
44
+
45
+ Expected callback actions:
46
+ pdef:<profile_id> set default
47
+ plog:<profile_id> get login url
48
+ pdel:<profile_id> delete profile (confirm by YES message)
49
+ """
50
  rows: list[list[InlineKeyboardButton]] = []
51
 
52
  default_profile_id = str(default_profile_id or "")
 
65
  status = "βœ…" if is_connected else ("πŸ”‘" if not has_refresh else "⚠️")
66
  title = f"{prefix}{status} [{i}] {label}"[:50]
67
 
68
+ # Title/info row (noop)
69
+ rows.append([InlineKeyboardButton(title, callback_data=make("noop", pid[:8] or "p"))])
70
 
71
+ # Action row
72
  btns: list[InlineKeyboardButton] = []
73
  if pid:
74
  btns.append(InlineKeyboardButton("βœ… Set default", callback_data=make("pdef", pid)))
75
  btns.append(InlineKeyboardButton("πŸ”— Login", callback_data=make("plog", pid)))
76
  btns.append(InlineKeyboardButton("πŸ—‘ Delete", callback_data=make("pdel", pid)))
 
77
  if btns:
78
  rows.append(btns)
79
 
80
+ # Optional error row
81
  if last_error:
82
  rows.append([InlineKeyboardButton(f"⚠️ {last_error[:48]}", callback_data=make("noop", "err"))])
83
 
 
85
  return InlineKeyboardMarkup(rows)
86
 
87
 
88
+ def upload_confirm_keyboard(privacy: str) -> InlineKeyboardMarkup:
89
  priv_label = {"private": "πŸ”’ Private", "unlisted": "πŸ”— Unlisted", "public": "🌍 Public"}.get(
90
  (privacy or "private").lower(), "πŸ”’ Private"
91
  )
 
 
 
 
 
 
92
  return InlineKeyboardMarkup(
93
  [
 
 
 
 
 
94
  [InlineKeyboardButton("βœ… Upload", callback_data=make(UP_GO))],
95
  [
96
  InlineKeyboardButton("✏️ Edit title/desc", callback_data=make(UP_EDIT)),
 
101
  InlineKeyboardButton("⬅️ Back", callback_data=make(BACK)),
102
  ],
103
  ]
104
+ )
105
+
106
+
107
+ def filename_keyboard() -> InlineKeyboardMarkup:
108
+ """
109
+ Used before upload to let user pick title source:
110
+ - Original filename
111
+ - Caption
112
+ - Custom
113
+ """
114
+ return InlineKeyboardMarkup(
115
+ [
116
+ [InlineKeyboardButton("πŸ“„ Original filename", callback_data=make(NAME_ORIGINAL))],
117
+ [InlineKeyboardButton("πŸ“ From caption", callback_data=make(NAME_CAPTION))],
118
+ [InlineKeyboardButton("✍️ Custom name", callback_data=make(NAME_CUSTOM))],
119
+ [InlineKeyboardButton("❌ Cancel", callback_data=make(CANCEL))],
120
+ ]
121
  )