38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
|
from aiogram import types
|
|||
|
|
|||
|
from load import dp, bot, messages
|
|||
|
from state.state import AddUser
|
|||
|
from utils.database.user import Register, User
|
|||
|
from keyboard.default.admin.main_menu import base_menu
|
|||
|
from keyboard.default.main_menu import back_to_main_menu
|
|||
|
|
|||
|
|
|||
|
|
|||
|
@dp.message_handler(lambda x: x.text == messages.add_admin, is_admin=True)
|
|||
|
async def add_admin(message: types.Message):
|
|||
|
await bot.send_message(
|
|||
|
message.chat.id,
|
|||
|
("Отправьте user_id пользователя\n"
|
|||
|
"Его можно узнать зайдя в информацию о пользователе"),
|
|||
|
reply_markup=base_menu()
|
|||
|
)
|
|||
|
await AddUser.user_id.set()
|
|||
|
|
|||
|
|
|||
|
@dp.message_handler(state=AddUser.user_id)
|
|||
|
async def add_admin1(message: types.Message, state):
|
|||
|
await state.finish()
|
|||
|
user_id = message.text
|
|||
|
if not user_id.isdigit() or "-100" in user_id:
|
|||
|
await bot.send_message(message.chat.id, "Данные не правильные!", reply_markup=back_to_main_menu)
|
|||
|
return
|
|||
|
|
|||
|
user_id = int(user_id)
|
|||
|
user = User.get_user(user_id)
|
|||
|
if not user:
|
|||
|
await bot.send_message(message.chat.id, "Пользователь не существует!", reply_markup=back_to_main_menu)
|
|||
|
return
|
|||
|
Register.register_admin(user)
|
|||
|
await bot.send_message(message.chat.id, "Администратор добавлен!", reply_markup=back_to_main_menu)
|
|||
|
|