feat(alerts): алерты всей команде — детекторы, дедупликация, список (#15)
CI / ruff · mypy · pytest (pull_request) Successful in 4m49s
CI / ruff · mypy · pytest (pull_request) Successful in 4m49s
- детекторы по состоянию после каждого раунда снапшотов: краш, OOM, цикл рестартов, unhealthy, перегрузка ≥ 1 мин, мало места, Docker недоступен; пороги в config/alerts.yaml - AlertService: ключ kind+service, повтор в 10 мин — счётчик в исходном сообщении, «✅ восстановлено» ответом; разовые события (🛡) со счётчиком - рассылка всем активным (🛡 — только админам), темп ~25/с, RetryAfter, заблокировавший бота пропускается; alert_deliveries для правок и ответов - «🚨 Алерты»: активные + 7 дней по 10, карточка; кнопки «📜 Логи», «🩺 Статус» под алертом открывают новое сообщение, а не затирают алерт - 🛡 атаки через агента идут через общий сервис алертов - убраны заглушки «Раздел в разработке» — у всех разделов свои роутеры Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
"""/start (incl. invite deep links), /help, /menu, main menu buttons and in-section navigation."""
|
||||
|
||||
from aiogram import F, Router
|
||||
from aiogram import Router
|
||||
from aiogram.filters import Command, CommandObject, CommandStart
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery, Message
|
||||
|
||||
from app.access.service import AccessService, RedeemStatus
|
||||
from app.bot.menu import Nav, NavAction, Section, main_menu, section_by_button, section_nav
|
||||
from app.bot.menu import Nav, NavAction, main_menu
|
||||
from app.bot.middlewares.access import tg_user
|
||||
from app.db.models import Role, User
|
||||
from app.texts import Texts
|
||||
@@ -14,10 +14,6 @@ from app.texts import Texts
|
||||
|
||||
def build_router(texts: Texts, access: AccessService) -> Router:
|
||||
router = Router(name="common")
|
||||
sections = section_by_button(texts)
|
||||
section_text = {
|
||||
Section.ALERTS: texts.section.alerts,
|
||||
}
|
||||
|
||||
@router.message(CommandStart())
|
||||
async def start(message: Message, command: CommandObject, state: FSMContext, member: User | None) -> None:
|
||||
@@ -46,12 +42,6 @@ def build_router(texts: Texts, access: AccessService) -> Router:
|
||||
async def help_(message: Message) -> None:
|
||||
await message.answer(texts.help.text)
|
||||
|
||||
# Sections with their own routers (members, commit) are matched there first
|
||||
@router.message(F.text.in_({k for k, v in sections.items() if v in section_text}))
|
||||
async def open_section(message: Message, state: FSMContext) -> None:
|
||||
await state.clear()
|
||||
await message.answer(section_text[sections[message.text or ""]], reply_markup=section_nav(texts))
|
||||
|
||||
@router.callback_query(Nav.filter())
|
||||
async def navigate(query: CallbackQuery, callback_data: Nav, state: FSMContext) -> None:
|
||||
# At a section's root "Back" and "Cancel" both close it; nested screens will override "Back" per section.
|
||||
|
||||
Reference in New Issue
Block a user