changed extension logic / fix: images when creating and back buttons

This commit is contained in:
Vladless
2025-10-10 03:36:19 +03:00
parent 2a0005248a
commit 8ffab98ec8
5 changed files with 21 additions and 12 deletions
+2 -2
View File
@@ -84,7 +84,7 @@ async def process_connect_pc(callback_query: CallbackQuery, session: Any):
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text=PC_PC, callback_data=f"windows_menu|{key_name}"))
builder.row(InlineKeyboardButton(text=PC_MACOS, callback_data=f"macos_menu|{key_name}"))
builder.row(InlineKeyboardButton(text=BACK, callback_data=f"view_key|{key_name}"))
builder.row(InlineKeyboardButton(text=BACK, callback_data=f"connect_device|{key_name}"))
await edit_or_send_message(
target_message=callback_query.message,
@@ -162,7 +162,7 @@ async def process_connect_tv(callback_query: CallbackQuery, session: Any):
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text=TV_CONTINUE, callback_data=f"continue_tv|{key_name}"))
builder.row(InlineKeyboardButton(text=BACK, callback_data=f"view_key|{key_name}"))
builder.row(InlineKeyboardButton(text=BACK, callback_data=f"connect_device|{key_name}"))
builder.row(InlineKeyboardButton(text=MAIN_MENU, callback_data="profile"))
await edit_or_send_message(
-1
View File
@@ -57,7 +57,6 @@ async def handle_connect_device(callback_query: CallbackQuery, session: AsyncSes
builder.row(InlineKeyboardButton(text=ANDROID, callback_data=f"connect_android|{key_name}"))
builder.row(InlineKeyboardButton(text=PC, callback_data=f"connect_pc|{key_name}"))
builder.row(InlineKeyboardButton(text=TV, callback_data=f"connect_tv|{key_name}"))
# builder.row(InlineKeyboardButton(text=ROUTER, callback_data=f"connect_router|{key_name}"))
builder.row(InlineKeyboardButton(text=BACK, callback_data=f"view_key|{key_name}"))
try:
+2 -4
View File
@@ -242,11 +242,9 @@ async def key_cluster_mode(
media_path=default_media_path,
)
else:
photo = FSInputFile(default_media_path)
await bot.send_photo(
await bot.send_message(
chat_id=tg_id,
photo=photo,
caption=key_message_text,
text=key_message_text,
reply_markup=builder.as_markup(),
)
+16 -1
View File
@@ -13,7 +13,7 @@ from sqlalchemy import or_, select, update
from sqlalchemy.ext.asyncio import AsyncSession
from bot import bot
from config import DISCOUNT_ACTIVE_HOURS, USE_NEW_PAYMENT_FLOW
from config import DISCOUNT_ACTIVE_HOURS, USE_NEW_PAYMENT_FLOW, RENEW_BUTTON_BEFORE_DAYS
from database import (
check_tariff_exists,
get_balance,
@@ -66,6 +66,21 @@ async def process_callback_renew_key(callback_query: CallbackQuery, state: FSMCo
server_id = record["server_id"]
tariff_id = record.get("tariff_id")
expiry_utc = datetime.utcfromtimestamp(expiry_time / 1000).replace(tzinfo=pytz.UTC)
available_from_utc = expiry_utc - timedelta(days=RENEW_BUTTON_BEFORE_DAYS)
now_utc = datetime.utcnow().replace(tzinfo=pytz.UTC)
if now_utc < available_from_utc:
dt_msk = available_from_utc.astimezone(moscow_tz).strftime("%d.%m.%Y %H:%M")
kb = InlineKeyboardBuilder()
kb.row(InlineKeyboardButton(text=BACK, callback_data=f"view_key|{key_name}"))
await edit_or_send_message(
target_message=callback_query.message,
text=f"Продление доступно с {dt_msk}",
reply_markup=kb.as_markup(),
)
return
await state.update_data(renew_key_name=key_name, renew_client_id=client_id)
logger.info(f"[RENEW] Получение тарифов для server_id={server_id}")
+1 -4
View File
@@ -26,7 +26,6 @@ from config import (
REMNAWAVE_LOGIN,
REMNAWAVE_PASSWORD,
REMNAWAVE_WEBAPP,
RENEW_BUTTON_BEFORE_DAYS,
TOGGLE_CLIENT,
USE_COUNTRY_SELECTION,
)
@@ -244,7 +243,6 @@ async def render_key_info(message: Message, session: Any, key_name: str, image_p
expiry_date = datetime.utcfromtimestamp(expiry_time / 1000)
now = datetime.utcnow()
time_left = expiry_date - now
show_renew_btn = time_left.total_seconds() <= RENEW_BUTTON_BEFORE_DAYS * 86400
if time_left.total_seconds() <= 0:
days_left_message = DAYS_LEFT_MESSAGE
@@ -342,8 +340,7 @@ async def render_key_info(message: Message, session: Any, key_name: str, image_p
else:
builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, callback_data=f"connect_device|{key_name}"))
if show_renew_btn:
builder.row(InlineKeyboardButton(text=RENEW_KEY, callback_data=f"renew_key|{key_name}"))
builder.row(InlineKeyboardButton(text=RENEW_KEY, callback_data=f"renew_key|{key_name}"))
if HWID_RESET_BUTTON and hwid_count > 0:
builder.row(InlineKeyboardButton(text=HWID_BUTTON, callback_data=f"reset_hwid|{key_name}"))