mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-05-02 02:36:26 +00:00
- Add pyproject.toml with uv and ruff configuration - Pin Python version to 3.13 via .python-version - Add Makefile commands: lint, format, fix - Apply ruff formatting to entire codebase - Remove unused imports (base64 in yookassa/simple_subscription) - Update .gitignore for new config files
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
from datetime import datetime
|
||
|
||
from aiogram import types
|
||
from sqlalchemy.ext.asyncio import AsyncSession
|
||
|
||
from app.database.models import Subscription, User
|
||
from app.services.admin_notification_service import AdminNotificationService
|
||
|
||
from .common import logger
|
||
|
||
|
||
async def send_trial_notification(
|
||
callback: types.CallbackQuery, db: AsyncSession, db_user: User, subscription: Subscription
|
||
):
|
||
try:
|
||
notification_service = AdminNotificationService(callback.bot)
|
||
await notification_service.send_trial_activation_notification(db, db_user, subscription)
|
||
except Exception as e:
|
||
logger.error(f'Ошибка отправки уведомления о триале: {e}')
|
||
|
||
|
||
async def send_purchase_notification(
|
||
callback: types.CallbackQuery,
|
||
db: AsyncSession,
|
||
db_user: User,
|
||
subscription: Subscription,
|
||
transaction_id: int,
|
||
period_days: int,
|
||
was_trial_conversion: bool = False,
|
||
):
|
||
try:
|
||
from app.database.crud.transaction import get_transaction_by_id
|
||
|
||
transaction = await get_transaction_by_id(db, transaction_id)
|
||
if transaction:
|
||
notification_service = AdminNotificationService(callback.bot)
|
||
await notification_service.send_subscription_purchase_notification(
|
||
db, db_user, subscription, transaction, period_days, was_trial_conversion
|
||
)
|
||
except Exception as e:
|
||
logger.error(f'Ошибка отправки уведомления о покупке: {e}')
|
||
|
||
|
||
async def send_extension_notification(
|
||
callback: types.CallbackQuery,
|
||
db: AsyncSession,
|
||
db_user: User,
|
||
subscription: Subscription,
|
||
transaction_id: int,
|
||
extended_days: int,
|
||
old_end_date: datetime,
|
||
):
|
||
try:
|
||
from app.database.crud.transaction import get_transaction_by_id
|
||
|
||
transaction = await get_transaction_by_id(db, transaction_id)
|
||
if transaction:
|
||
notification_service = AdminNotificationService(callback.bot)
|
||
await notification_service.send_subscription_extension_notification(
|
||
db, db_user, subscription, transaction, extended_days, old_end_date
|
||
)
|
||
except Exception as e:
|
||
logger.error(f'Ошибка отправки уведомления о продлении: {e}')
|