refactor: summary after keyword list, remove separators, back button in admin
This commit is contained in:
+24
-3
@@ -150,7 +150,6 @@ def _kw_action_keyboard(kw_id: str, is_active: bool) -> InlineKeyboardMarkup:
|
|||||||
[InlineKeyboardButton(toggle_btn, callback_data=f"toggle:{sid}"),
|
[InlineKeyboardButton(toggle_btn, callback_data=f"toggle:{sid}"),
|
||||||
InlineKeyboardButton("✏️ Edit", callback_data=f"edit_menu:{sid}")],
|
InlineKeyboardButton("✏️ Edit", callback_data=f"edit_menu:{sid}")],
|
||||||
[InlineKeyboardButton("🗑 Remove", callback_data=f"remove_confirm:{sid}")],
|
[InlineKeyboardButton("🗑 Remove", callback_data=f"remove_confirm:{sid}")],
|
||||||
[InlineKeyboardButton("↩ Back to Menu", callback_data="menu:")],
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -181,6 +180,7 @@ def _admin_menu_keyboard() -> InlineKeyboardMarkup:
|
|||||||
[InlineKeyboardButton("➕ Add User", callback_data="admin_add"),
|
[InlineKeyboardButton("➕ Add User", callback_data="admin_add"),
|
||||||
InlineKeyboardButton("👥 List Users", callback_data="admin_list")],
|
InlineKeyboardButton("👥 List Users", callback_data="admin_list")],
|
||||||
[InlineKeyboardButton("🗑 Remove User", callback_data="admin_remove")],
|
[InlineKeyboardButton("🗑 Remove User", callback_data="admin_remove")],
|
||||||
|
[InlineKeyboardButton("↩ Back", callback_data="menu:")],
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -192,7 +192,6 @@ def _format_kw_card(kw: dict) -> str:
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
f"<b>🔍 {kw['keyword']}</b>\n"
|
f"<b>🔍 {kw['keyword']}</b>\n"
|
||||||
f"━━━━━━━━━━━━━━━━━━━━━\n"
|
|
||||||
f"{status_icon} | Interval: <code>{kw['interval_minutes']} min</code>\n"
|
f"{status_icon} | Interval: <code>{kw['interval_minutes']} min</code>\n"
|
||||||
f"Last scrape: {_vienna_time(kw.get('last_scraped_at'))}{subs_line}"
|
f"Last scrape: {_vienna_time(kw.get('last_scraped_at'))}{subs_line}"
|
||||||
)
|
)
|
||||||
@@ -507,6 +506,14 @@ async def _handle_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) -
|
|||||||
chat_id=chat_id, text=text, parse_mode="HTML", reply_markup=kb,
|
chat_id=chat_id, text=text, parse_mode="HTML", reply_markup=kb,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
name = user["first_name"] or "there"
|
||||||
|
await context.bot.send_message(
|
||||||
|
chat_id=chat_id,
|
||||||
|
text=f"<b>That was all your listings, {name}!</b>\n\nAnything else I can help with?",
|
||||||
|
parse_mode="HTML",
|
||||||
|
reply_markup=_main_menu_keyboard(),
|
||||||
|
)
|
||||||
|
|
||||||
elif sub == "stats":
|
elif sub == "stats":
|
||||||
total_kw = await pool.fetchval(
|
total_kw = await pool.fetchval(
|
||||||
"SELECT COUNT(DISTINCT ks.keyword_id) FROM keyword_subscriptions ks WHERE ks.user_id = $1",
|
"SELECT COUNT(DISTINCT ks.keyword_id) FROM keyword_subscriptions ks WHERE ks.user_id = $1",
|
||||||
@@ -518,13 +525,26 @@ async def _handle_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) -
|
|||||||
|
|
||||||
text = (
|
text = (
|
||||||
"<b>📊 Tracking Statistics</b>\n"
|
"<b>📊 Tracking Statistics</b>\n"
|
||||||
"━━━━━━━━━━━━━━━━━━━━━\n\n"
|
|
||||||
f"Keywords: <code>{total_kw}</code>\n"
|
f"Keywords: <code>{total_kw}</code>\n"
|
||||||
f"Ads indexed: <code>{total_ads}</code>\n"
|
f"Ads indexed: <code>{total_ads}</code>\n"
|
||||||
f"Notifications sent: <code>{total_notifs}</code>"
|
f"Notifications sent: <code>{total_notifs}</code>"
|
||||||
)
|
)
|
||||||
await query.edit_message_text(text=text, parse_mode="HTML")
|
await query.edit_message_text(text=text, parse_mode="HTML")
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Empty payload — "Back" button from sub-menus, show main menu
|
||||||
|
name = update.effective_user.first_name or "there"
|
||||||
|
kb = _main_menu_keyboard()
|
||||||
|
try:
|
||||||
|
await query.edit_message_text(
|
||||||
|
f"Hello <b>{name}</b>! I'll notify you about new willhaben listings.",
|
||||||
|
parse_mode="HTML", reply_markup=kb)
|
||||||
|
except Exception:
|
||||||
|
await context.bot.send_message(
|
||||||
|
chat_id=chat_id or user["telegram_id"],
|
||||||
|
text=f"Hello <b>{name}</b>! I'll notify you about new willhaben listings.",
|
||||||
|
parse_mode="HTML", reply_markup=kb)
|
||||||
|
|
||||||
# ════════════════════════════════════════════════════════════════════
|
# ════════════════════════════════════════════════════════════════════
|
||||||
# CANCEL / BACK
|
# CANCEL / BACK
|
||||||
# ════════════════════════════════════════════════════════════════════
|
# ════════════════════════════════════════════════════════════════════
|
||||||
@@ -801,6 +821,7 @@ async def _handle_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) -
|
|||||||
kb = InlineKeyboardMarkup([
|
kb = InlineKeyboardMarkup([
|
||||||
[InlineKeyboardButton("➕ Add User", callback_data="admin_add"),
|
[InlineKeyboardButton("➕ Add User", callback_data="admin_add"),
|
||||||
InlineKeyboardButton("🗑 Remove User", callback_data="admin_remove")],
|
InlineKeyboardButton("🗑 Remove User", callback_data="admin_remove")],
|
||||||
|
[InlineKeyboardButton("↩ Back", callback_data="menu:")],
|
||||||
])
|
])
|
||||||
await query.edit_message_text(text=text, parse_mode="HTML", reply_markup=kb)
|
await query.edit_message_text(text=text, parse_mode="HTML", reply_markup=kb)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user