fix QRCode, False DISCOUNTS and name profile

This commit is contained in:
Vladless
2025-03-29 21:57:36 +03:00
parent 738590a265
commit ca2b671be9
2 changed files with 16 additions and 14 deletions
+12 -12
View File
@@ -316,7 +316,7 @@ async def process_callback_view_key(callback_query: CallbackQuery, session: Any)
builder.row(
InlineKeyboardButton(
text=QR,
callback_data=f"show_qr|{key}",
callback_data=f"show_qr|{key_name}",
)
)
if ENABLE_DELETE_KEY_BUTTON:
@@ -367,13 +367,9 @@ async def process_callback_view_key(callback_query: CallbackQuery, session: Any)
@router.callback_query(F.data.startswith("show_qr|"))
async def show_qr_code(callback_query: types.CallbackQuery, session: Any):
try:
key_value = callback_query.data.split("|")[1]
record = await session.fetchrow(
"SELECT key, email FROM keys WHERE key = $1",
key_value,
)
key_name = callback_query.data.split("|")[1]
record = await session.fetchrow("SELECT key, email FROM keys WHERE email = $1", key_name)
if not record:
await callback_query.message.answer("❌ Подписка не найдена.")
return
@@ -845,10 +841,13 @@ async def process_callback_renew_key(callback_query: CallbackQuery, session: Any
for plan_id, plan_details in RENEWAL_PLANS.items():
months = plan_details["months"]
price = plan_details["price"]
discount = DISCOUNTS.get(plan_id, 0)
button_text = f"📅 {months} месяц{'а' if months > 1 else ''} ({price} руб.)" + (
f" {discount}% скидка" if discount > 0 else ""
)
discount = DISCOUNTS.get(plan_id, 0) if isinstance(DISCOUNTS, dict) else 0
button_text = f"📅 {months} месяц{'а' if months > 1 else ''} ({price} руб.)"
if discount > 0:
button_text += f" {discount}% скидка"
builder.row(
InlineKeyboardButton(
text=button_text,
@@ -874,7 +873,8 @@ async def process_callback_renew_key(callback_query: CallbackQuery, session: Any
else:
await callback_query.message.answer("<b>Ключ не найден.</b>")
except Exception as e:
logger.error(e)
logger.error(f"Ошибка в process_callback_renew_key: {e}")
await callback_query.message.answer("❌ Произошла ошибка при обработке. Попробуйте позже.")
@router.callback_query(F.data.startswith("renew_plan|"))
+4 -2
View File
@@ -69,13 +69,15 @@ async def process_callback_view_profile(
):
if isinstance(callback_query_or_message, CallbackQuery):
chat_id = callback_query_or_message.message.chat.id
username = html.escape(callback_query_or_message.from_user.full_name)
user = callback_query_or_message.from_user
target_message = callback_query_or_message.message
else:
chat_id = callback_query_or_message.chat.id
username = html.escape(callback_query_or_message.from_user.full_name)
user = callback_query_or_message.from_user
target_message = callback_query_or_message
username = html.escape(user.full_name) if user and user.full_name else "Пользователь"
image_path = os.path.join("img", "profile.jpg")
logger.info(f"Переход в профиль. Используется изображение: {image_path}")