fix: fix /start command not working - router order issue
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build encountered an error

PROBLEM:
- /start command was not responding
- Chat router was intercepting all text messages including commands
- Main router with /start handler was connected AFTER chat_router

ROOT CAUSE:
- chat_router has @router.message(F.text) handler that catches ALL text
- It was connected BEFORE main router with Command('start') handler
- chat_router returned early for /start, preventing main handler from running

SOLUTION:
1. Move main router (with /start, /help, /admin) to FIRST position
2. Keep chat_router LAST (catches only unhandled messages)
3. Remove /start and /help from chat_handlers command list (handled earlier)

ROUTER ORDER (priority):
1. router (main.py) - base commands
2. admin_router - admin panel
3. registration_router
4. admin_account_router
5. admin_chat_router
6. redraw_router
7. account_router
8. chat_router - LAST (catch-all for broadcasts)

ALSO FIXED:
- Add missing imports in admin_panel.py: Lottery, Participation, Account
- Fixes NameError crashes in cleanup functions
This commit is contained in:
2025-11-17 06:56:50 +09:00
parent 72e95db811
commit 0dc0ae8111
3 changed files with 11 additions and 8 deletions

10
main.py
View File

@@ -145,17 +145,19 @@ async def main():
logger.info("Запуск бота...")
# Подключаем роутеры в правильном порядке
# 1. Сначала специфичные роутеры
# 1. Основной роутер main.py с базовыми командами (/start, /help, /admin)
dp.include_router(router)
# 2. Специфичные роутеры
dp.include_router(admin_router) # Админ панель - самая высокая специфичность
dp.include_router(registration_router) # Регистрация
dp.include_router(admin_account_router) # Админские команды счетов
dp.include_router(admin_chat_router) # Админские команды чата
dp.include_router(redraw_router) # Повторные розыгрыши
dp.include_router(account_router) # Пользовательские счета
dp.include_router(chat_router) # Пользовательский чат (последним - ловит все сообщения)
# 2. Основной роутер main.py
dp.include_router(router)
# 3. Chat router ПОСЛЕДНИМ (ловит все необработанные сообщения)
dp.include_router(chat_router) # Пользовательский чат (последним - ловит все сообщения)
# Запускаем polling
try: