fix QRCode, False DISCOUNTS and name profile
This commit is contained in:
+12
-12
@@ -316,7 +316,7 @@ async def process_callback_view_key(callback_query: CallbackQuery, session: Any)
|
|||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=QR,
|
text=QR,
|
||||||
callback_data=f"show_qr|{key}",
|
callback_data=f"show_qr|{key_name}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if ENABLE_DELETE_KEY_BUTTON:
|
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|"))
|
@router.callback_query(F.data.startswith("show_qr|"))
|
||||||
async def show_qr_code(callback_query: types.CallbackQuery, session: Any):
|
async def show_qr_code(callback_query: types.CallbackQuery, session: Any):
|
||||||
try:
|
try:
|
||||||
key_value = callback_query.data.split("|")[1]
|
key_name = callback_query.data.split("|")[1]
|
||||||
|
|
||||||
record = await session.fetchrow(
|
|
||||||
"SELECT key, email FROM keys WHERE key = $1",
|
|
||||||
key_value,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
record = await session.fetchrow("SELECT key, email FROM keys WHERE email = $1", key_name)
|
||||||
if not record:
|
if not record:
|
||||||
await callback_query.message.answer("❌ Подписка не найдена.")
|
await callback_query.message.answer("❌ Подписка не найдена.")
|
||||||
return
|
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():
|
for plan_id, plan_details in RENEWAL_PLANS.items():
|
||||||
months = plan_details["months"]
|
months = plan_details["months"]
|
||||||
price = plan_details["price"]
|
price = plan_details["price"]
|
||||||
discount = DISCOUNTS.get(plan_id, 0)
|
|
||||||
button_text = f"📅 {months} месяц{'а' if months > 1 else ''} ({price} руб.)" + (
|
discount = DISCOUNTS.get(plan_id, 0) if isinstance(DISCOUNTS, dict) else 0
|
||||||
f" {discount}% скидка" if discount > 0 else ""
|
|
||||||
)
|
button_text = f"📅 {months} месяц{'а' if months > 1 else ''} ({price} руб.)"
|
||||||
|
if discount > 0:
|
||||||
|
button_text += f" {discount}% скидка"
|
||||||
|
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=button_text,
|
text=button_text,
|
||||||
@@ -874,7 +873,8 @@ async def process_callback_renew_key(callback_query: CallbackQuery, session: Any
|
|||||||
else:
|
else:
|
||||||
await callback_query.message.answer("<b>Ключ не найден.</b>")
|
await callback_query.message.answer("<b>Ключ не найден.</b>")
|
||||||
except Exception as e:
|
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|"))
|
@router.callback_query(F.data.startswith("renew_plan|"))
|
||||||
|
|||||||
+4
-2
@@ -69,13 +69,15 @@ async def process_callback_view_profile(
|
|||||||
):
|
):
|
||||||
if isinstance(callback_query_or_message, CallbackQuery):
|
if isinstance(callback_query_or_message, CallbackQuery):
|
||||||
chat_id = callback_query_or_message.message.chat.id
|
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
|
target_message = callback_query_or_message.message
|
||||||
else:
|
else:
|
||||||
chat_id = callback_query_or_message.chat.id
|
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
|
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")
|
image_path = os.path.join("img", "profile.jpg")
|
||||||
logger.info(f"Переход в профиль. Используется изображение: {image_path}")
|
logger.info(f"Переход в профиль. Используется изображение: {image_path}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user