Files
tg-sd/bot/handlers_start.py
dinlo b88ccf3b4b Initial commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 18:46:09 +08:00

52 lines
2.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Обработчик команды /start и главного меню."""
from aiogram import Router
from aiogram.filters import CommandStart, Command
from aiogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from config import settings
router = Router()
def get_main_keyboard(user_id: int = None) -> InlineKeyboardMarkup:
"""Создать главное меню."""
keyboard = InlineKeyboardMarkup(inline_keyboard=[
[
InlineKeyboardButton(text="🎨 Генерация (txt2img)", callback_data="gen_txt2img"),
],
[
InlineKeyboardButton(text="⚙️ Профили", callback_data="profiles_menu"),
InlineKeyboardButton(text="🗑️ Настройки хранения", callback_data="storage_settings"),
],
[
InlineKeyboardButton(text="📊 Статус SD API", callback_data="check_sd_status"),
InlineKeyboardButton(text="️ Помощь", callback_data="help"),
],
])
# Добавляем кнопку админ-панели для админа
if user_id and user_id == settings.ADMIN_ID:
keyboard.inline_keyboard.insert(0, [
InlineKeyboardButton(text="🛡️ Админ-панель", callback_data="admin_panel"),
])
return keyboard
@router.message(CommandStart())
async def cmd_start(message: Message):
"""Обработка команды /start."""
text = (
f"👋 <b>Привет, {message.from_user.first_name}!</b>\n\n"
"Я бот для генерации изображений через Stable Diffusion.\n"
"Выберите действие из меню ниже:"
)
await message.answer(text, reply_markup=get_main_keyboard(message.from_user.id), parse_mode="HTML")
@router.message(Command("menu"))
async def cmd_menu(message: Message):
"""Обработка команды /menu."""
await message.answer("📋 Главное меню:", reply_markup=get_main_keyboard(message.from_user.id))