| | |
| | | "warn_limit": "Лимит варнов", |
| | | "warn_action": "Действие при лимите", |
| | | "warn_duration": "Длительность наказания, сек", |
| | | "flood_enabled": "Антифлуд", |
| | | "flood_count": "Порог сообщений", |
| | | "flood_window": "Окно антифлуда, сек", |
| | | "flood_mute": "Мут за флуд, сек", |
| | | "flood_alarm_mute": "Мут за флуд в тревоге, сек", |
| | | "new_member_days": "Новый участник, дней", |
| | | "no_links": "Фильтр ссылок", |
| | | "slow_mode": "Медленный режим в тревоге, сек", |
| | | } |
| | | |
| | | |
| | |
| | | if k[0] in ids |
| | | ] |
| | | logs = [row for row in await db.list_log(limit=300) if row["chat_id"] in ids][:10] |
| | | alarms = [r for r in await db.list_alarm_chats() if r["chat_id"] in ids] |
| | | return render( |
| | | request, "dashboard.html", active="dash", st=st, captchas=captchas, logs=logs, names=names |
| | | request, |
| | | "dashboard.html", |
| | | active="dash", |
| | | st=st, |
| | | captchas=captchas, |
| | | logs=logs, |
| | | names=names, |
| | | alarms=alarms, |
| | | ) |
| | | |
| | | |
| | |
| | | user = await _user(request) |
| | | chats = await allowed_chats(user["user_id"]) |
| | | cfgs = {c["chat_id"]: await db.get_chat_cfg(c["chat_id"]) for c in chats} |
| | | return render(request, "chats.html", active="chats", chats=chats, cfgs=cfgs) |
| | | alarms = {r["chat_id"]: r for r in await db.list_alarm_chats()} |
| | | return render(request, "chats.html", active="chats", chats=chats, cfgs=cfgs, alarms=alarms) |
| | | |
| | | |
| | | async def chat_page(request) -> web.Response: |
| | |
| | | if not await pm.check_perm(chat_id, user["user_id"], P_ALARM): |
| | | raise web.HTTPForbidden() |
| | | if enabled: |
| | | await alarm.enable_alarm(chat_id, user["user_id"]) |
| | | try: |
| | | hours = int(data.get("hours", "24")) |
| | | except ValueError: |
| | | hours = 24 |
| | | hours = max(1, min(720, hours)) |
| | | await alarm.enable_alarm(chat_id, user["user_id"], now_ts() + hours * 3600) |
| | | else: |
| | | await alarm.disable_alarm(chat_id, user["user_id"]) |
| | | raise web.HTTPFound(f"/chats/{chat_id}") |
| | |
| | | "warn_limit": int(data["warn_limit"]), |
| | | "warn_action": data["warn_action"], |
| | | "warn_duration": int(data["warn_duration"]), |
| | | "flood_enabled": int(data.get("flood_enabled", "0")), |
| | | "flood_count": int(data["flood_count"]), |
| | | "flood_window": int(data["flood_window"]), |
| | | "flood_mute": int(data["flood_mute"]), |
| | | "flood_alarm_mute": int(data["flood_alarm_mute"]), |
| | | "new_member_days": int(data["new_member_days"]), |
| | | "no_links": int(data.get("no_links", "0")), |
| | | "slow_mode": int(data["slow_mode"]), |
| | | } |
| | | except (KeyError, ValueError): |
| | | raise web.HTTPFound(f"/chats/{chat_id}?err=cfg") |