fix middlewares, gifts and more

This commit is contained in:
Vladless
2025-09-19 02:45:25 +03:00
parent b68b539c68
commit 81751093d9
4 changed files with 25 additions and 4 deletions
+20 -1
View File
@@ -43,7 +43,24 @@ async def errors_handler(event: ErrorEvent, bot: Bot) -> bool:
or "message can't be deleted for everyone" in error_message
or "message to delete not found" in error_message
):
logger.warning("Отправляем стартовое меню.")
try:
tb = "".join(traceback.format_exception(type(event.exception), event.exception, event.exception.__traceback__))
logger.warning(f"Показываем стартовое меню из-за TelegramBadRequest: {error_message}")
logger.error(f"Traceback:\n{tb}")
if ADMIN_ID:
for admin_id in ADMIN_ID:
await bot.send_document(
chat_id=admin_id,
document=BufferedInputFile(
tb.encode(),
filename=f"error_{event.update.update_id}.txt",
),
caption=f"{hbold(type(event.exception).__name__)}: {error_message[:1021]}...",
)
except Exception as e:
logger.error(f"Сбой при логировании/отправке ошибки админу: {e}", exc_info=True)
try:
from handlers.start import start_entry
@@ -129,3 +146,5 @@ async def errors_handler(event: ErrorEvent, bot: Bot) -> bool:
logger.warning(f"Не удалось отправить детали ошибки: {exception}")
except Exception as exception:
logger.error(f"Неожиданная ошибка в error handler: {exception}")
return True
+2 -2
View File
@@ -239,8 +239,8 @@ async def show_start_menu(message: Message, admin: bool, session: AsyncSession):
trial_status = await get_trial(session, message.chat.id) if session else None
show_trial = (trial_status == 0) and (not TRIAL_TIME_DISABLE)
show_profile = ((not SHOW_START_MENU_ONCE) or (trial_status != 0) or TRIAL_TIME_DISABLE) and (trial_status != -1) and (not show_trial)
show_trial = (trial_status in (-1, 0)) and (not TRIAL_TIME_DISABLE)
show_profile = ((not SHOW_START_MENU_ONCE) or (trial_status not in (-1, 0)) or TRIAL_TIME_DISABLE) and (not show_trial)
if show_trial:
kb.row(InlineKeyboardButton(text=TRIAL_SUB, callback_data="create_key"))
+3 -1
View File
@@ -59,7 +59,9 @@ class DirectStartBlockerMiddleware(BaseMiddleware):
return exists
if not text.startswith("/"):
return await handler(event, data)
if await user_exists_cached():
return await handler(event, data)
return
parts = text.split(maxsplit=1)
if parts[0] != "/start":