From 73b6edff9f3bfec1852fbfba8e97bb3416561416 Mon Sep 17 00:00:00 2001 From: Vladless Date: Tue, 7 Oct 2025 13:48:48 +0300 Subject: [PATCH] fix Tribute flow --- handlers/payments/currency_flow.py | 12 +++++++++--- handlers/payments/fast_payment_flow.py | 3 ++- handlers/payments/pay.py | 6 ++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/handlers/payments/currency_flow.py b/handlers/payments/currency_flow.py index 547e76b7..97e5e96d 100644 --- a/handlers/payments/currency_flow.py +++ b/handlers/payments/currency_flow.py @@ -8,19 +8,25 @@ from config import TRIBUTE_LINK from .currency_rates import format_for_user -def build_currency_choice_kb(show_stars: bool, *, prefix: str = "choose_payment_currency") -> InlineKeyboardBuilder: +def build_currency_choice_kb( + show_stars: bool, + *, + prefix: str = "choose_payment_currency", + show_tribute: bool | None = None, +) -> InlineKeyboardBuilder: kb = InlineKeyboardBuilder() kb.row(InlineKeyboardButton(text=RUB_CURRENCY, callback_data=f"{prefix}|RUB")) kb.row(InlineKeyboardButton(text=USD_CURRENCY, callback_data=f"{prefix}|USD")) trib = (TRIBUTE_LINK or "").strip() + trib_enabled = (bool(trib) if show_tribute is None else bool(show_tribute) and bool(trib)) if show_stars: row = [InlineKeyboardButton(text=STARS, callback_data=f"{prefix}|STARS")] - if trib.startswith("https://"): + if trib_enabled: row.append(InlineKeyboardButton(text="TRIBUTE", url=trib)) kb.row(*row) else: - if trib.startswith("https://"): + if trib_enabled: kb.row(InlineKeyboardButton(text="TRIBUTE", url=trib)) kb.row(InlineKeyboardButton(text=MAIN_MENU, callback_data="profile")) diff --git a/handlers/payments/fast_payment_flow.py b/handlers/payments/fast_payment_flow.py index 349d8b7b..064f903e 100644 --- a/handlers/payments/fast_payment_flow.py +++ b/handlers/payments/fast_payment_flow.py @@ -106,7 +106,8 @@ async def try_fast_payment_flow( if MULTICURRENCY_ENABLE: show_stars = bool((PROVIDERS.get("STARS") or {}).get("enabled")) - kb = build_currency_choice_kb(show_stars=show_stars) + show_tribute = bool((PROVIDERS.get("TRIBUTE") or {}).get("enabled")) + kb = build_currency_choice_kb(show_stars=show_stars, show_tribute=show_tribute) lead = await shortfall_lead_text( session, tg_id, required_amount, getattr(callback_query.from_user, "language_code", None) ) diff --git a/handlers/payments/pay.py b/handlers/payments/pay.py index 7285672b..a5a94c77 100644 --- a/handlers/payments/pay.py +++ b/handlers/payments/pay.py @@ -45,10 +45,12 @@ async def handle_pay(callback_query: CallbackQuery, state: FSMContext, session: payment_handlers.append(fn) module_buttons = await run_hooks("pay_menu_buttons", chat_id=callback_query.from_user.id, admin=False, session=session) - has_extra_menu_items = bool(module_buttons) or bool(DONATIONS_ENABLE) or PROVIDERS.get("TRIBUTE", {}).get("enabled") + has_extra_menu_items = bool(module_buttons) or bool(DONATIONS_ENABLE) or bool((PROVIDERS.get("TRIBUTE") or {}).get("enabled")) if MULTICURRENCY_ENABLE: - kb = build_currency_choice_kb(show_stars=bool(PROVIDERS.get("STARS", {}).get("enabled")), prefix="pay_currency") + show_stars = bool((PROVIDERS.get("STARS") or {}).get("enabled")) + show_tribute = bool((PROVIDERS.get("TRIBUTE") or {}).get("enabled")) + kb = build_currency_choice_kb(show_stars=show_stars, prefix="pay_currency", show_tribute=show_tribute) await edit_or_send_message( target_message=callback_query.message, text=FAST_PAY_CHOOSE_CURRENCY,