правки

This commit is contained in:
Vlad
2024-09-23 19:08:41 +03:00
parent be35180703
commit 3fa93a9b72
2 changed files with 21 additions and 2 deletions
+11 -2
View File
@@ -9,6 +9,7 @@ import os
from bot import bot
from config import ADMIN_ID, CHANNEL_URL
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
router = Router()
@@ -31,7 +32,12 @@ async def send_welcome_message(chat_id: int):
await bot.send_message(chat_id, "Файл изображения не найден.")
return
# Создаем клавиатуру
# Создаем клавиатуру с кнопкой "Старт"
keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
start_button = KeyboardButton(text='/start')
keyboard.add(start_button)
# Создаем inline-клавиатуру
inline_keyboard = InlineKeyboardMarkup(inline_keyboard=[
[InlineKeyboardButton(text='👤 Мой профиль', callback_data='view_profile')],
[InlineKeyboardButton(text='🔒 О VPN', callback_data='about_vpn')],
@@ -49,9 +55,12 @@ async def send_welcome_message(chat_id: int):
),
caption=welcome_text,
parse_mode='Markdown',
reply_markup=inline_keyboard
reply_markup=inline_keyboard # Inline-клавиатура
)
# Отправляем клавиатуру с кнопкой "Старт"
await bot.send_message(chat_id, "Нажмите /start для повторного запуска.", reply_markup=keyboard)
@router.message(Command('start'))
async def start_command(message: Message):
await send_welcome_message(message.chat.id)
+10
View File
@@ -19,6 +19,8 @@ from database import (add_connection, get_balance, has_active_key, store_key,
update_balance)
from handlers.profile import process_callback_view_profile
from handlers.start import start_command
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
router = Router()
@@ -87,6 +89,12 @@ async def cancel_create_key(callback_query: CallbackQuery, state: FSMContext):
await process_callback_view_profile(callback_query, state)
await callback_query.answer()
def start_keyboard():
keyboard = ReplyKeyboardMarkup(resize_keyboard=True)
start_button = KeyboardButton(text='/start')
keyboard.add(start_button)
return keyboard
# Обработка текстовых сообщений
@dp.message()
async def handle_text(message: Message, state: FSMContext):
@@ -114,6 +122,8 @@ async def handle_text(message: Message, state: FSMContext):
if current_state == Form.waiting_for_key_name.state:
await handle_key_name_input(message, state)
await message.answer("Выберите действие:", reply_markup=start_keyboard())
async def handle_key_name_input(message: Message, state: FSMContext):
tg_id = message.from_user.id