From 25ab024b4c1677d411024b36323a06a18711e28a Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Sun, 11 Oct 2026 15:33:55 +0000
Subject: [PATCH] feat: просмотр последних сообщений чата в отдельном окне и отправка от имени Амадеуса с пометкой автора

---
 report.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/report.py b/report.py
index cd88fc3..1af52fe 100644
--- a/report.py
+++ b/report.py
@@ -1,9 +1,10 @@
 from aiogram import types
 from aiogram.filters import Command, CommandObject
 
+import cfg
 import db
 from cfg import dp
-from util import now_ts
+from util import now_ts, refuse_report_phrase
 
 # Антиспам: не более REPORT_LIMIT репортов за REPORT_WINDOW секунд,
 # иначе блокировка на REPORT_BLOCK секунд.
@@ -23,8 +24,19 @@
 
     # Цель репорта: автор сообщения, на которое ответили.
     target_id = 0
-    if message.reply_to_message and message.reply_to_message.from_user:
-        target_id = message.reply_to_message.from_user.id
+    target_msg_id = 0
+    target_text = ""
+    if message.reply_to_message:
+        target_msg_id = message.reply_to_message.message_id
+        src = message.reply_to_message
+        target_text = (src.text or src.caption or "")[:500]
+        if src.from_user:
+            target_id = src.from_user.id
+
+    # Нельзя жаловаться на бота и на себя.
+    if target_id and (target_id == cfg.BOT_ID or target_id == user_id):
+        await message.reply(refuse_report_phrase())
+        return
 
     text = (command.args or "").strip()
     if not text and not target_id:
@@ -43,6 +55,6 @@
         await message.reply("Слишком много репортов подряд. Отправка заблокирована на сутки.")
         return
 
-    await db.add_report(chat_id, user_id, target_id, text, ts)
+    await db.add_report(chat_id, user_id, target_id, text, ts, target_msg_id, target_text)
     await db.add_log(chat_id, user_id, target_id, "report", text[:200], ts)
     await message.reply("Репорт отправлен администрации.")

--
Gitblit v1.9.3