understanding commited on
Commit
5d41ce9
Β·
verified Β·
1 Parent(s): 9f108c3

Update bot/ui/keyboards.py

Browse files
Files changed (1) hide show
  1. bot/ui/keyboards.py +12 -24
bot/ui/keyboards.py CHANGED
@@ -38,15 +38,6 @@ def auth_menu_keyboard() -> InlineKeyboardMarkup:
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
- handlers.py expects 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,10 +56,8 @@ def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> Inl
65
  status = "βœ…" if is_connected else ("πŸ”‘" if not has_refresh else "⚠️")
66
  title = f"{prefix}{status} [{i}] {label}"[:50]
67
 
68
- # Title/info row
69
  rows.append([InlineKeyboardButton(title, callback_data=make("noop", pid[:8]))])
70
 
71
- # Action row
72
  btns: list[InlineKeyboardButton] = []
73
  if pid:
74
  btns.append(InlineKeyboardButton("βœ… Set default", callback_data=make("pdef", pid)))
@@ -78,7 +67,6 @@ def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> Inl
78
  if btns:
79
  rows.append(btns)
80
 
81
- # Optional small error row (if present)
82
  if last_error:
83
  rows.append([InlineKeyboardButton(f"⚠️ {last_error[:48]}", callback_data=make("noop", "err"))])
84
 
@@ -86,12 +74,23 @@ def profiles_keyboard(profiles: list[dict], default_profile_id: str = "") -> Inl
86
  return InlineKeyboardMarkup(rows)
87
 
88
 
89
- def upload_confirm_keyboard(privacy: str) -> InlineKeyboardMarkup:
90
  priv_label = {"private": "πŸ”’ Private", "unlisted": "πŸ”— Unlisted", "public": "🌍 Public"}.get(
91
  (privacy or "private").lower(), "πŸ”’ Private"
92
  )
 
 
 
 
 
 
93
  return InlineKeyboardMarkup(
94
  [
 
 
 
 
 
95
  [InlineKeyboardButton("βœ… Upload", callback_data=make(UP_GO))],
96
  [
97
  InlineKeyboardButton("✏️ Edit title/desc", callback_data=make(UP_EDIT)),
@@ -102,15 +101,4 @@ def upload_confirm_keyboard(privacy: str) -> InlineKeyboardMarkup:
102
  InlineKeyboardButton("⬅️ Back", callback_data=make(BACK)),
103
  ],
104
  ]
105
- )
106
-
107
-
108
- def filename_keyboard() -> InlineKeyboardMarkup:
109
- return InlineKeyboardMarkup(
110
- [
111
- [InlineKeyboardButton("πŸ“„ Original filename", callback_data=make(NAME_ORIGINAL))],
112
- [InlineKeyboardButton("πŸ“ From caption", callback_data=make(NAME_CAPTION))],
113
- [InlineKeyboardButton("✍️ Custom name", callback_data=make(NAME_CUSTOM))],
114
- [InlineKeyboardButton("❌ Cancel", callback_data=make(CANCEL))],
115
- ]
116
  )
 
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
  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)))
 
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
  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
  InlineKeyboardButton("⬅️ Back", callback_data=make(BACK)),
102
  ],
103
  ]
 
 
 
 
 
 
 
 
 
 
 
104
  )