2022-06-04 22:02:51 +03:00
|
|
|
|
from aiogram import types
|
2022-06-16 00:32:17 +03:00
|
|
|
|
from aiogram.dispatcher import FSMContext
|
2022-06-04 22:02:51 +03:00
|
|
|
|
|
|
|
|
|
from load import dp, bot, messages
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
2022-06-16 00:32:17 +03:00
|
|
|
|
@dp.message_handler(lambda x: x.text == messages.add_operator, is_admin=True)
|
|
|
|
|
async def add_operator(message: types.Message, state: FSMContext):
|
2022-06-04 22:02:51 +03:00
|
|
|
|
await bot.send_message(
|
|
|
|
|
message.chat.id,
|
|
|
|
|
("Отправьте user_id пользователя\n"
|
2022-06-05 15:02:41 +03:00
|
|
|
|
"Его можно узнать зайдя в информацию о пользователе"),
|
2022-06-04 22:02:51 +03:00
|
|
|
|
reply_markup=base_menu()
|
|
|
|
|
)
|
2022-06-16 00:32:17 +03:00
|
|
|
|
await state.set_state("get_user_id_add_operator")
|
2022-06-04 22:02:51 +03:00
|
|
|
|
|
|
|
|
|
|
2022-06-16 00:32:17 +03:00
|
|
|
|
@dp.message_handler(is_admin=True, state="get_user_id_add_operator")
|
|
|
|
|
async def add_operator1(message: types.Message, state: FSMContext):
|
2022-06-04 22:02:51 +03:00
|
|
|
|
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
|
2022-06-16 00:32:17 +03:00
|
|
|
|
Register.register_operator(user)
|
|
|
|
|
await bot.send_message(message.chat.id, "Оператор добавлен!", reply_markup=back_to_main_menu)
|