From 47fba49d1835442f096739b92a3dd3ed9476470b Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Fri, 04 Dec 2026 11:14:16 +0000
Subject: [PATCH] Fix API error handling: return JSON on auth failure for API routes

---
 captcha.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/captcha.py b/captcha.py
index c3d06aa..a44e8f0 100644
--- a/captcha.py
+++ b/captcha.py
@@ -81,12 +81,15 @@
     if user.is_bot:
         return
 
+    chat_id = event.chat.id
+    user_id = user.id
+    # Фиксируем время входа — нужно, чтобы отличать новых участников от старых.
+    await db.set_join(chat_id, user_id, int(time.time()))
+
     # Режим тревоги: при рейде кикает вход и отменяет капчу.
     if await alarm.handle_join(event):
         return
 
-    chat_id = event.chat.id
-    user_id = user.id
     cfg = await db.get_chat_cfg(chat_id)
 
     # until_date задаёт запас: при перезапуске бота Telegram сам снимет ограничение.

--
Gitblit v1.9.3