示例#1
0

async def add_new_admin(message, state, user_id):
    await update_admin_status(user_id, True)
    user = await select_user(user_id)
    editor = await select_user(message.from_user.id)
    if int(message.from_user.id) != int(config.SUPERUSER_ID[0]):
        await message.answer(f"Пользователь: {user.name}\n"
                             f"Имя: {user.full_name}\n"
                             f"id: {user.id}\n"
                             f"Успешно наделен правами администратора")
    await new_admin_added_mailing(editor, user)
    await state.finish()


@dp.message_handler(Command("get_admins"), IsAdminFilter())
async def show_admins_list(message: types.Message):
    admins = await select_all_admins()
    admins_list = ["<b>Список администраторов</b>"]
    admin_number = 1
    for admin in admins:
        admins_list.append(admins_text.format(
            number=admin_number,
            user_name=admin.name,
            full_name=admin.full_name,
            admin_id=admin.id
        ))
        admin_number += 1
    await message.answer("\n".join(admins_list))

from aiogram import types
from aiogram.dispatcher.filters import Command

from app.filters.IsAdmin import IsAdminFilter
from app.loader import dp
from app.utils.misc import rate_limit


@rate_limit(5, "admin_commands")
@dp.message_handler(Command("admin_commands"), IsAdminFilter())
async def show_admin_commands(message: types.Message):
    admin_commands_text = [
        "<b>Команды для администратора</b>:\n",
        "/subject - Управление предметами",
        "/event - Управление событиями",
        "/teacher - Управление преподавателями",
        "/timetable_edit - Управление расписанием",
        "/get_admins - Отличается от /show_admins наличием user_name и user_id",
    ]
    await message.answer("\n".join(admin_commands_text))
示例#3
0
    for user in users:
        if user.subscription:
            await bot.send_message(chat_id=user.id,
                                   text=f"Добавлено новое событие для предмета <b>{subject_name}</b>")


# ---------------------------------------------
# file events_customization.py:
#
# contains functions for edit events:
# 1. add new event
# 2. delete event
# ---------------------------------------------


@dp.message_handler(Command("event"), IsAdminFilter())
async def show_events_customization_menu(message: Union[types.Message, types.CallbackQuery]):
    subjects = await select_all_subjects()
    if isinstance(message, types.Message):
        await message.answer("Меню событий предметов",
                             reply_markup=set_subjects_for_events_edit_keyboard(subjects=subjects))
    elif isinstance(message, types.CallbackQuery):
        call = message
        await call.answer()
        await call.message.edit_text("Меню событий предметов",
                                     reply_markup=set_subjects_for_events_edit_keyboard(subjects=subjects))


@dp.callback_query_handler(text_contains="select_subject_to_event_edit")
async def show_acts_for_edit_events(call: CallbackQuery):
    await call.answer()
    set_teachers_list_keyboard, teachers_customization_cd, set_cancel_action_keyboard, \
    set_acts_for_edit_selected_teacher_keyboard
from app.loader import dp, bot
from app.states.teachers import EditTeacher, GetTeacher
from app.utils.db_api.quick_commands import quick_commands_teachers
from app.utils.db_api.quick_commands.quick_commands_subjects import select_subject
from app.utils.db_api.quick_commands.quick_commands_teachers import update_teacher_name, \
    select_teacher, delete_teacher, update_teacher_mail


async def check_mail(mail):
    return re.match(r"[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+",
                    mail) or mail == "Отсутствует"


@dp.message_handler(Command("teacher"), IsAdminFilter())
async def show_teachers_customization_menu(message: types.Message):
    await show_subjects_list(message)


async def show_subjects_list(message: Union[types.Message,
                                            types.CallbackQuery], **kwargs):
    markup = await set_subjects_keyboard()

    if isinstance(message, types.Message):
        await message.answer("Меню редактирования информации о преподавателях",
                             reply_markup=markup)
    elif isinstance(message, types.CallbackQuery):
        call = message
        await call.answer()
        await call.message.edit_text(
from aiogram import types
from aiogram.dispatcher.filters import Command
from aiogram.types import CallbackQuery

from app.filters.IsAdmin import IsAdminFilter
from app.keyboards.inline.zoom_links_keyboard import show_subjects_for_links_edit, add_or_remove_links
from app.loader import dp
from app.utils.db_api.quick_commands.quick_commands_subjects import select_all_subjects, select_subject


@dp.message_handler(Command("zoom"), IsAdminFilter())
async def show_subjects_for_link_edit(message: types.Message):
    subjects = await select_all_subjects()
    await message.answer("Меню редактирования ZOOM ссылок",
                         reply_markup=show_subjects_for_links_edit(subjects))


@dp.callback_query_handler(text_contains="select_subject_to_link_edit")
async def show_acts_with_links(call: CallbackQuery):
    await call.answer(cache_time=60)
    subject_id = call.data.split(":")[-1]
    subject = await select_subject(subject_id=subject_id)
    await call.message.answer(f"Меню редактирования ZOOM ссылок для предмета: <b>{subject}</b>",
                              reply_markup=add_or_remove_links(subject_id=subject_id))


@dp.callback_query_handler(text_contains="add_link")
async def show_links_edit_menu(call: CallbackQuery):
    await call.answer(cache_time=60)
示例#6
0
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters import Command
from aiogram.types import CallbackQuery

from app.filters.IsAdmin import IsAdminFilter
from app.keyboards.inline.timetable_keyboards.timetable_customization_keyboard import timetable_edit_cd, \
    set_days_for_edit_keyboard, \
    set_couples_keyboard, set_status_of_the_week_keyboard, set_acts_for_edit_keyboard, set_cancel_keyboard
from app.loader import dp, bot
from app.states.get_couple import GetCouple
from app.utils.db_api.quick_commands.quick_commands_timetable import edit_couple_name_even, edit_couple_name_odd, \
    delete_couple_name_even, delete_couple_name_odd
from app.utils.misc.texts.timetable import days, reverse_classes


@dp.message_handler(Command("timetable_edit"), IsAdminFilter())
async def show_timetable_customization_menu(message: types.Message):
    await show_list_days(message)


async def show_list_days(message: Union[types.Message, types.CallbackQuery],
                         **kwargs):
    markup = await set_days_for_edit_keyboard()

    if isinstance(message, types.Message):
        await message.answer(f"<b>Редактирование расписания</b>",
                             reply_markup=markup)

    elif isinstance(message, types.CallbackQuery):
        call = message
        await call.answer()
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters import Command
from aiogram.types import CallbackQuery

from app.filters.IsAdmin import IsAdminFilter
from app.keyboards.inline.cancel_keyboard import set_cancel_keyboard
from app.keyboards.inline.subjects_customization_keyboards.edit_subject_keyboard import edit_subject_keyboard
from app.keyboards.inline.subjects_customization_keyboards.show_subjects_for_subjects_edit import \
    set_subjects_list_keyboard
from app.loader import dp, bot
from app.utils.db_api.quick_commands.quick_commands_subjects import add_subject, delete_subject, \
    select_subject, select_all_subjects
from app.utils.db_api.quick_commands.quick_commands_zoom import add_link


@dp.message_handler(Command("subject"), IsAdminFilter())
async def show_subjects_customization_menu(
        message: Union[types.Message, types.CallbackQuery]):
    subjects = await select_all_subjects()
    if isinstance(message, types.Message):
        await message.answer("Меню действий с предметами",
                             reply_markup=set_subjects_list_keyboard(subjects))
    elif isinstance(message, types.CallbackQuery):
        call = message
        await call.answer()
        await call.message.edit_text(
            text="Меню действий с предметами",
            reply_markup=set_subjects_list_keyboard(subjects))


@dp.callback_query_handler(text_contains="add_new_subject")