From 0250410ca754b8f24594df608536bcf085dd1efa Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Sun, 11 Oct 2026 16:29:50 +0000
Subject: [PATCH] feat web: чат пузырями (свои/чужие), превью реплаев, подгрузка фото/стикеров/медиа через бота

---
 mod.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/mod.py b/mod.py
index b8469aa..9adda98 100644
--- a/mod.py
+++ b/mod.py
@@ -7,6 +7,7 @@
 
 import db
 import cfg
+import alarm
 from cfg import OWNER_ID, FULL_PERMS, NO_PERMS, DEF_WARN_EXPIRE, bot, dp, logger
 from perms import P_BAN, P_MUTE, P_UNBAN, P_UNMUTE, P_UNWARN, P_WARN, check_perm, member_status
 from util import fmt_dur, mention, msg_target, now_ts, parse_dur, refuse_phrase, refuse_self_phrase, resolve_usr
@@ -20,8 +21,10 @@
 
 # --- Ядро действий ---
 
-async def apply_mute(chat_id: int, user_id: int, name: str, until: Optional[int], admin_id: int, reason: str) -> bool:
+async def apply_mute(chat_id: int, user_id: int, name: str, dur: Optional[int], admin_id: int, reason: str) -> bool:
+    # dur — длительность в секундах (None или 0 = бессрочно). until_date — абсолютное время.
     ts = now_ts()
+    until = None if not dur else ts + dur
     try:
         await bot.restrict_chat_member(chat_id, user_id, permissions=NO_PERMS, until_date=until)
     except Exception as e:
@@ -29,12 +32,13 @@
         return False
     await db.add_punish(chat_id, user_id, "mute", admin_id, reason, ts, until)
     await db.add_log(chat_id, admin_id, user_id, "mute", reason, ts)
-    await _notice(chat_id, f"Пользователь {mention(user_id, name)} замучен на {fmt_dur(until)}. Причина: {reason or '-'}")
+    await _notice(chat_id, f"Пользователь {mention(user_id, name)} замучен на {fmt_dur(dur)}. Причина: {reason or '-'}")
     return True
 
 
-async def apply_ban(chat_id: int, user_id: int, name: str, until: Optional[int], admin_id: int, reason: str) -> bool:
+async def apply_ban(chat_id: int, user_id: int, name: str, dur: Optional[int], admin_id: int, reason: str) -> bool:
     ts = now_ts()
+    until = None if not dur else ts + dur
     try:
         await bot.ban_chat_member(chat_id, user_id)
     except Exception as e:
@@ -42,7 +46,7 @@
         return False
     await db.add_punish(chat_id, user_id, "ban", admin_id, reason, ts, until)
     await db.add_log(chat_id, admin_id, user_id, "ban", reason, ts)
-    await _notice(chat_id, f"Пользователь {mention(user_id, name)} забанен на {fmt_dur(until)}. Причина: {reason or '-'}")
+    await _notice(chat_id, f"Пользователь {mention(user_id, name)} забанен на {fmt_dur(dur)}. Причина: {reason or '-'}")
     return True
 
 
@@ -269,6 +273,7 @@
 async def _bg_tick() -> None:
     ts = now_ts()
     await db.exp_warns(ts)
+    await alarm.expire_check(ts)
     for row in await db.due_unbans(ts):
         chat_id = row["chat_id"]
         user_id = row["user_id"]

--
Gitblit v1.9.3