52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
|
|
"""Обработчик команды /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))
|