Files
remnawave-bedolaga-telegram…/app/handlers/subscription/happ.py
c0mrade 9a2aea038a chore: add uv package manager and ruff linter configuration
- 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
2026-01-24 17:45:27 +03:00

86 lines
3.1 KiB
Python

from aiogram import types
from aiogram.types import InaccessibleMessage
from sqlalchemy.ext.asyncio import AsyncSession
from app.config import settings
from app.database.models import User
from app.keyboards.inline import get_happ_download_link_keyboard, get_happ_download_platform_keyboard
from app.localization.texts import get_texts
async def handle_happ_download_request(callback: types.CallbackQuery, db_user: User, db: AsyncSession):
texts = get_texts(db_user.language)
prompt_text = texts.t(
'HAPP_DOWNLOAD_PROMPT',
'📥 <b>Скачать Happ</b>\nВыберите ваше устройство:',
)
keyboard = get_happ_download_platform_keyboard(db_user.language)
await callback.message.answer(prompt_text, reply_markup=keyboard, parse_mode='HTML')
await callback.answer()
async def handle_happ_download_platform_choice(callback: types.CallbackQuery, db_user: User, db: AsyncSession):
# Проверяем, доступно ли сообщение для редактирования
if isinstance(callback.message, InaccessibleMessage):
await callback.answer()
return
platform = callback.data.split('_')[-1]
if platform == 'pc':
platform = 'windows'
texts = get_texts(db_user.language)
link = settings.get_happ_download_link(platform)
if not link:
await callback.answer(
texts.t('HAPP_DOWNLOAD_LINK_NOT_SET', '❌ Ссылка для этого устройства не настроена'),
show_alert=True,
)
return
platform_names = {
'ios': texts.t('HAPP_PLATFORM_IOS', '🍎 iOS'),
'android': texts.t('HAPP_PLATFORM_ANDROID', '🤖 Android'),
'macos': texts.t('HAPP_PLATFORM_MACOS', '🖥️ Mac OS'),
'windows': texts.t('HAPP_PLATFORM_WINDOWS', '💻 Windows'),
}
link_text = texts.t(
'HAPP_DOWNLOAD_LINK_MESSAGE',
'⬇️ Скачайте Happ для {platform}:',
).format(platform=platform_names.get(platform, platform.upper()))
keyboard = get_happ_download_link_keyboard(db_user.language, link)
await callback.message.edit_text(link_text, reply_markup=keyboard, parse_mode='HTML')
await callback.answer()
async def handle_happ_download_close(callback: types.CallbackQuery, db_user: User, db: AsyncSession):
try:
await callback.message.delete()
except Exception:
pass
await callback.answer()
async def handle_happ_download_back(callback: types.CallbackQuery, db_user: User, db: AsyncSession):
# Проверяем, доступно ли сообщение для редактирования
if isinstance(callback.message, InaccessibleMessage):
await callback.answer()
return
texts = get_texts(db_user.language)
prompt_text = texts.t(
'HAPP_DOWNLOAD_PROMPT',
'📥 <b>Скачать Happ</b>\nВыберите ваше устройство:',
)
keyboard = get_happ_download_platform_keyboard(db_user.language)
await callback.message.edit_text(prompt_text, reply_markup=keyboard, parse_mode='HTML')
await callback.answer()