fix Tribute flow

This commit is contained in:
Vladless
2025-10-07 13:48:48 +03:00
parent 1084fac243
commit 73b6edff9f
3 changed files with 15 additions and 6 deletions
+9 -3
View File
@@ -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"))
+2 -1
View File
@@ -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)
)
+4 -2
View File
@@ -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,