Merge branch 'dev'

This commit is contained in:
Vladless
2025-05-01 21:26:14 +03:00
2 changed files with 14 additions and 14 deletions
@@ -47,7 +47,6 @@ from handlers.texts import (
)
from handlers.utils import format_hours, format_minutes
from logger import logger
from handlers.utils import format_hours, format_months, format_minutes
from .notify_utils import send_messages_with_limit, send_notification
from .special_notifications import notify_inactive_trial_users, notify_users_no_traffic
@@ -420,9 +419,7 @@ async def process_auto_renew_or_notify(
)
renewed_message = KEY_RENEWED.format(
email=email,
months_formatted=months_formatted,
expiry_date=formatted_expiry_date
email=email, months=renewal_period_months, expiry_date=formatted_expiry_date
)
keyboard = build_notification_expired_kb()
@@ -444,4 +441,4 @@ async def process_auto_renew_or_notify(
logger.info(f"📢 Отправлено уведомление об истекающей подписке {email} пользователю {tg_id}.")
await add_notification(tg_id, notification_id, session=conn)
else:
logger.warning(f"📢 Не удалось отправить уведомление об истекающей подписке {email} пользователю {tg_id}.")
logger.warning(f"📢 Не удалось отправить уведомление об истекающей подписке {email} пользователю {tg_id}.")
@@ -75,16 +75,19 @@ async def notify_inactive_trial_users(bot: Bot, conn: asyncpg.Connection):
display_name=display_name, trial_time_formatted=format_days(TRIAL_TIME)
)
messages.append({
"tg_id": tg_id,
"text": message,
"keyboard": keyboard,
})
await add_notification(tg_id, "inactive_trial", session=conn)
try:
await bot.send_message(tg_id, message, reply_markup=keyboard)
logger.info(f"📩 Отправлено уведомление неактивному пользователю {tg_id}.")
await add_notification(tg_id, "inactive_trial", session=conn)
if messages:
await send_messages_with_limit(bot, messages)
logger.info(f"Отправлено {len(messages)} уведомлений неактивным пользователям.")
except TelegramForbiddenError:
logger.warning(f"🚫 Бот заблокирован пользователем {tg_id}. Добавляем в blocked_users.")
await create_blocked_user(tg_id, conn)
except Exception as e:
logger.error(f"⚠ Ошибка при отправке уведомления пользователю {tg_id}: {e}")
await asyncio.sleep(1)
logger.info("✅ Проверка пользователей с неактивным пробным периодом завершена.")