First commit

This commit is contained in:
2026-01-23 04:45:55 +07:00
commit 0b251c5967
118 changed files with 9580 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
from aiogram import Router, F
from aiogram.types import Message
from bot.data.topic_map import user_topic_map
router: Router = Router(name="topic_replies")
@router.message(F.is_topic_message, F.reply_to_message, ~F.from_user.is_bot)
async def forward_reply_to_user(message: Message):
thread_id = message.message_thread_id
if thread_id is None:
return # нет thread_id, выходим
# Найдем user_id по thread_id
user_id = None
for (uid, kind), tid in user_topic_map.items():
if tid == thread_id:
user_id = uid
break
if user_id is None:
return # Топик не зарегистрирован
reply_text = f"<b>Ответ администратора:</b>\n{message.html_text}"
try:
await message.bot.send_message(chat_id=user_id, text=reply_text, parse_mode="HTML")
except Exception as e:
await message.reply(f"⚠️ Не удалось отправить сообщение пользователю: {e}")