예제 #1
0
async def _save_list(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)

    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("main"))

    await ans.answer("Список сохранён", keyboard=kbs.group.list_menu())
예제 #2
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _confirm_send_alarm(ans: bots.SimpleBotEvent):

    student_id = students.get_system_id_of_student(ans.from_id)
    admin_store = managers.AdminConfigManager(student_id)
    state_storage = managers.StateStorageManager(student_id)
    state_storage.update(state=state_storage.get_id_of_state("main"))

    fin_store = managers.FinancialConfigManager(student_id)

    with orm.db_session:
        chat_vk_id = admin_store.get_active_chat().vk_id
        category_name = fin_store.get_or_create().financial_category.name
        category_sum = fin_store.get_or_create().financial_category.summ

    await ans.api_ctx.messages.send(
        peer_id=chat_vk_id,
        random_id=0,
        message="Начат сбор средств на {0}. Сумма {1} руб.".format(
            category_name,
            category_sum,
        ),
    )

    await ans.answer(
        "Сообщение отправлено",
        keyboard=kbs.finances.fin_prefs(),
    )
예제 #3
0
async def _remove_list(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)

    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("groups_remove_list"))
    await ans.answer("Удалить список?",
                     keyboard=kbs.common.prompt().get_keyboard())
예제 #4
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _call_debtors(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    group_id = admin.get_active_group(admin_id)
    state_store = managers.StateStorageManager(admin_id)
    admin_store = managers.AdminConfigManager(admin_id)
    fin_store = managers.FinancialConfigManager(admin_id)
    with orm.db_session:
        if chats.get_list_of_chats_by_group(group_id):
            category_id = fin_store.get_or_create().financial_category.id
            msgs = generate_debtors_call(category_id)
            state_store.update(state=state_store.get_id_of_state(
                "fin_confirm_debtors_call"), )
            chat_id = admin_store.get_active_chat().vk_id
            chat_title = await chat_utils.get_chat_name(api_context, chat_id)
            for msg in msgs:
                await ans.answer(msg)
            if len(msgs) > 1:
                text = "Сообщения будут отправлены в {0}"
            else:
                text = "Сообщение будет отправлено в {0}"
            await ans.answer(
                text.format(chat_title),
                keyboard=kbs.common.confirm_with_chat_update(),
            )
        else:
            await ans.answer(
                "У вашей группы нет зарегистрированных чатов. Возврат в главное меню",
                keyboard=kbs.finances.fin_category(),
            )
예제 #5
0
파일: start.py 프로젝트: uni-jacob/jacob
async def _register_call_message(ans: bots.SimpleBotEvent):
    attachments = ""
    message = ans.object.object.message
    raw_attachments = message.attachments
    admin_id = students.get_system_id_of_student(message.from_id)
    if message.is_cropped:
        extended_message = await ans.api_ctx.messages.get_by_id(message.id)
        raw_attachments = extended_message.response.items[0].attachments
    if raw_attachments:
        attachments = await media.load_attachments(
            api_context,
            raw_attachments,
            ans.object.object.message.peer_id,
        )
        await ans.answer("Загрузка вложений может занять некоторое время")
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(
        state=state_store.get_id_of_state("mention_select_mentioned"),
    )
    mention_store = managers.MentionStorageManager(admin_id)
    mention_store.update_text(ans.object.object.message.text)
    mention_store.update_attaches(attachments)
    await ans.answer(
        "Сообщение сохранено. Выберите призываемых студентов",
        keyboard=kbs.call.CallNavigator(admin_id).render().menu(),
    )
예제 #6
0
async def _delete_student(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)

    student_id = await redis.hget(
        "students_selected_students:{0}".format(ans.from_id),
        "student_id",
    )
    with orm.db_session:
        student = models.Student[student_id]
        is_admin = students.is_admin_in_group(
            student_id,
            admin.get_active_group(admin_id).id,
        )
    if int(student_id) != admin_id:
        state_store.update(
            state=state_store.get_id_of_state("students_delete_student"))
        await ans.answer(
            "Удалить студента {0} {1}?".format(student.first_name,
                                               student.last_name),
            keyboard=kbs.common.prompt().get_keyboard(),
        )
    else:
        await ans.answer(
            "Вы не можете удалить сами себя",
            keyboard=kbs.students.student_card(is_admin),
        )
예제 #7
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _register_category(ans: bots.SimpleBotEvent):
    if re.match(r"^\w+ \d+$", ans.object.object.message.text):
        message = ans.object.object.message
        student_id = students.get_system_id_of_student(message.from_id)
        category = finances.get_or_create_finances_category(
            admin.get_active_group(student_id).id,
            *message.text.split(),
        )
        admin_store = managers.AdminConfigManager(student_id)
        fin_store = managers.FinancialConfigManager(student_id)
        fin_store.update(financial_category=category.id)
        state_storage = managers.StateStorageManager(student_id)
        state_storage.update(
            state=state_storage.get_id_of_state("fin_send_alert"), )
        with orm.db_session:
            chat_id = admin_store.get_active_chat().vk_id

        chat_title = await chat_utils.get_chat_name(api_context, chat_id)

        await ans.answer(
            "Категория {0} зарегистрирована. Вы можете отправить сообщение о начале сбора в чат {1}"
            .format(
                category.name,
                chat_title,
            ),
            keyboard=kbs.common.confirm_with_chat_update(),
        )
    else:
        await ans.answer("Неверный формат данных")
예제 #8
0
async def _cancel_editing_student(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(
        state=state_store.get_id_of_state("students_select_student"))

    await ans.answer("Редактирование отменено",
                     keyboard=kbs.students.edit_menu())
예제 #9
0
async def _cancel_saving_list(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("main"))
    await ans.answer(
        "Создание списка отменено",
        keyboard=kbs.group.list_of_lists(admin.get_active_group(admin_id).id),
    )
예제 #10
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _rename_category(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("fin_wait_new_name"))
    await ans.answer(
        "Введите новое название категории",
        keyboard=kbs.common.cancel().get_keyboard(),
    )
예제 #11
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _cancel_creating_category(ans: bots.SimpleBotEvent):
    student_id = students.get_system_id_of_student(ans.from_id)
    state_storage = managers.StateStorageManager(student_id)
    state_storage.update(state=state_storage.get_id_of_state("main"))
    await ans.answer(
        "Создание категории отменено",
        keyboard=kbs.finances.list_of_fin_categories(student_id, ),
    )
예제 #12
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _update_category_sum(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("fin_wait_new_sum"))
    await ans.answer(
        "Введите новую сумму сбора",
        keyboard=kbs.common.cancel().get_keyboard(),
    )
예제 #13
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _cancel_changing_sum_of_category(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("main"))
    await ans.answer(
        "Изменение суммы отменено",
        keyboard=kbs.finances.fin_prefs(),
    )
예제 #14
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _cancel_remove_cat(ans: bots.SimpleBotEvent):
    student_id = students.get_system_id_of_student(ans.from_id)
    state_storage = managers.StateStorageManager(student_id)
    state_storage.update(state=state_storage.get_id_of_state("main"))
    await ans.answer(
        "Отмена",
        keyboard=kbs.finances.fin_prefs(),
    )
예제 #15
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _cancel_send_alarm(ans: bots.SimpleBotEvent):
    student_id = students.get_system_id_of_student(ans.from_id)
    state_storage = managers.StateStorageManager(student_id)
    state_storage.update(state=state_storage.get_id_of_state("main"))
    await ans.answer(
        "Хорошо, уведемление отправлено не будет",
        keyboard=kbs.finances.fin_category(),
    )
예제 #16
0
async def _edit_student_name(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("students_edit_name"))

    await ans.answer(
        "Введите новое имя",
        keyboard=kbs.common.cancel().get_keyboard(),
    )
예제 #17
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _add_income(ans: bots.SimpleBotEvent):
    student_id = students.get_system_id_of_student(ans.from_id)
    state_storage = managers.StateStorageManager(student_id)
    state_storage.update(
        state=state_storage.get_id_of_state("fin_select_donater"))
    await ans.answer(
        "Выберите студента, сдавшего деньги",
        keyboard=kbs.finances.IncomeNavigator(student_id, ).render().menu(),
    )
예제 #18
0
async def _start_reporting(ans: bots.SimpleBotEvent):
    state_manager = managers.StateStorageManager(
        students.get_system_id_of_student(ans.from_id), )
    state_manager.update(
        state=state_manager.get_id_of_state("report_wait_title"), )
    await ans.answer(
        "Отправьте заголовок проблемы, кратко описывающий произошедшее",
        keyboard=kbs.common.empty(),
    )
예제 #19
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _add_expense(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(
        state=state_store.get_id_of_state("fin_enter_expense_sum"))
    await ans.answer(
        "Введите сумму расхода",
        keyboard=kbs.common.cancel().get_keyboard(),
    )
예제 #20
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _create_category(ans: bots.SimpleBotEvent):
    state_storage = managers.StateStorageManager(
        students.get_system_id_of_student(ans.from_id), )
    state_storage.update(
        state=state_storage.get_id_of_state("fin_wait_category_desc"))
    await ans.answer(
        "Отправьте название категории и сумму сбора, разделенные пробелом",
        keyboard=kbs.common.cancel().get_keyboard(),
    )
예제 #21
0
파일: start.py 프로젝트: uni-jacob/jacob
async def _cancel_call(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.object.object.message.from_id)
    managers.MentionStorageManager(admin_id).clear()
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("main"))
    await ans.answer(
        "Призыв отменён. Возврат на главную.",
        keyboard=kbs.main.main_menu(admin_id),
    )
예제 #22
0
async def _edit_student_subgroup(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(
        state=state_store.get_id_of_state("students_edit_subgroup"))

    await ans.answer(
        "Введите номер подгруппы",
        keyboard=kbs.common.cancel_with_cleanup(),
    )
예제 #23
0
async def _start_renaming_list(ans: bots.SimpleBotEvent):

    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("groups_rename_list"))

    await ans.answer(
        "Введите новое имя списка",
        keyboard=kbs.common.cancel().get_keyboard(),
    )
예제 #24
0
async def _edit_student_email(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(
        state=state_store.get_id_of_state("students_edit_email"))

    await ans.answer(
        "Введите электропочту",
        keyboard=kbs.common.cancel_with_cleanup(),
    )
예제 #25
0
파일: start.py 프로젝트: uni-jacob/jacob
async def _skip_register_call_message(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.object.object.message.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(
        state=state_store.get_id_of_state("mention_select_mentioned"),
    )
    await ans.answer(
        "Выберите призываемых студентов",
        keyboard=kbs.call.CallNavigator(admin_id).render().menu(),
    )
예제 #26
0
async def _save_new_list_name(ans: bots.SimpleBotEvent):
    list_id = await redis.hget("current_list:{0}".format(ans.from_id),
                               "list_id")
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("main"))

    with orm.db_session:
        models.List[list_id].set(name=ans.text)

    await ans.answer("Список переименован", keyboard=kbs.group.list_menu())
예제 #27
0
async def _start_students(ans: bots.SimpleBotEvent):
    state_storage = managers.StateStorageManager(
        students.get_system_id_of_student(ans.from_id), )
    state_storage.update(
        state=state_storage.get_id_of_state("students_select_student"))
    await ans.answer(
        "Выберите студента",
        keyboard=kbs.contacts.ContactsNavigator(
            students.get_system_id_of_student(
                ans.from_id, ), ).render().menu(),
    )
예제 #28
0
async def _list_of_chats(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)
    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("pref_select_chat"))
    await ans.answer(
        "Список подключенных чатов",
        keyboard=await kbs.preferences.connected_chats(
            api_context,
            students.get_system_id_of_student(ans.from_id, ),
        ),
    )
예제 #29
0
async def _confirm_saving_list(ans: bots.SimpleBotEvent):
    admin_id = students.get_system_id_of_student(ans.from_id)

    with orm.db_session:
        models.List(group=admin.get_active_group(admin_id), name=ans.text)

    state_store = managers.StateStorageManager(admin_id)
    state_store.update(state=state_store.get_id_of_state("main"))

    await ans.answer("Список создан")
    await _start_lists(ans)
예제 #30
0
파일: finances.py 프로젝트: uni-jacob/jacob
async def _select_student(ans: bots.SimpleBotEvent):
    student_id = students.get_system_id_of_student(ans.from_id)
    state_storage = managers.StateStorageManager(student_id)
    state_storage.update(
        state=state_storage.get_id_of_state("fin_enter_donate_sum"))

    await redis.hmset(
        "add_income:{0}".format(ans.from_id),
        payer=ans.payload.get("student_id"),
    )
    await ans.answer("Введите сумму дохода", keyboard=kbs.common.empty())