Untitled

mail@pastecode.io avatar
unknown
python
a month ago
4.5 kB
2
Indexable
Never
def register_handlers(dp: Dispatcher):
    dp.register_message_handler(handlers.cmd_start_staff,
                                commands=context.commands.start.name)

    # ========== Отмена ==========
    dp.register_message_handler(
        handlers.cmd_cancel_staff,
        lambda message: message.text in [context.commands.cancel.description,
                                         f"/{context.commands.cancel.name}"],
        state="*")

    dp.register_callback_query_handler(
        handlers.process_after_notification,
        Text(startswith='another_position'),
        state="*")

    # ========== Оповещение о готовности заказа ==========
    dp.register_message_handler(
        handlers.cmd_order_is_ready,
        Text(equals=context.commands.notify_about_order_ru.name),
        state="*")
    dp.register_message_handler(
        handlers.cmd_order_is_ready,
        commands=context.commands.notify_about_order_en.name,
        state="*"
    )

    # ========== Обработка номера заказа ==========
    dp.register_message_handler(
        handlers.process_order_is_ready,
        state=bot_state.OrderIsReady.order_number)

    dp.register_message_handler(
        handlers.process_waiting_comment,
        state=bot_state.OrderIsReady.waiting_comment)

    # ========== Удаление заказа ==========
    dp.register_message_handler(
        cmd_delete_order,
        commands=context.commands.delete_order.name,
        state="*")
    dp.register_message_handler(
        process_delete_order_number,
        lambda message: message.text.isdigit(),
        state=bot_state.DeleteOrder.order_number)

    # Обработка введенного номера заказа без команды
    dp.register_message_handler(handlers.cmd_number_staff,
                                lambda message: message.text.isdigit())
    dp.register_callback_query_handler(
            handlers.callback_subscribe_on_order,
            Text(startswith="is_subscription_")
        )

    # ========== Статистика ==========
    dp.register_message_handler(handlers.cmd_statistics,
                                commands=context.commands.statistics.name)
    dp.register_message_handler(handlers.cmd_statistics,
                                Text(equals="🍲📊 Статистика по заказам"))
    dp.register_message_handler(handlers.cmd_statistics,
                                Text(equals="📊🕺 Статистика по пользователям"))
    dp.register_message_handler(handlers.get_most_active_users_all_time,
                                Text(equals="📊🕺 за всё время"))
    dp.register_message_handler(handlers.get_most_active_users_for_period,
                                Text(startswith="📊🕺 за последние"))

    # ========== Рассылка ==========
    dp.register_message_handler(handlers.cmd_create_mailing,
                                commands=context.commands.create_mailing.name,
                                state="*")
    dp.register_message_handler(handlers.check_mailing_text,
                                lambda message: message.text in ['Норм', 'Переделать'],
                                state=bot_state.Mailing.waiting_mailing_text,
                                )
    dp.register_message_handler(handlers.process_waiting_mailing_text,
                                state=bot_state.Mailing.waiting_mailing_text)
    dp.register_message_handler(handlers.process_waiting_users,
                                state=bot_state.Mailing.waiting_users)
    dp.register_message_handler(handlers.process_waiting_sending,
                                state=bot_state.Mailing.waiting_sending)

    # ========== Обновление меню ==========
    dp.register_message_handler(handlers.cmd_update_menu,
                                commands=context.commands.update_menu.name,
                                state="*")
    dp.register_message_handler(handlers.process_waiting_menu,
                                state=bot_state.UpdateMenu.waiting_menu,
                                content_types=types.ContentTypes.DOCUMENT)
    dp.register_message_handler(handlers.process_waiting_menu,
                                lambda message: message.document is None,
                                state=bot_state.UpdateMenu.waiting_menu,
                                )
Leave a Comment