Separate staff roles and protect message delivery with operator guides
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-09-13 21:00:53 +09:00
parent d5a9c13b68
commit 3c1a6a02a5
25 changed files with 916 additions and 548 deletions

View File

@@ -1,12 +1,26 @@
"""Copy user messages without losing Telegram entities, including custom emoji."""
import asyncio
from functools import wraps
from aiogram.types import Message, MessageEntity
COPY_TIMEOUT = 15.0
def bounded_copy(func):
@wraps(func)
async def wrapped(*args, **kwargs):
async with asyncio.timeout(COPY_TIMEOUT):
return await func(*args, **kwargs)
return wrapped
def utf16_length(text: str) -> int:
"""Telegram entity offsets count UTF-16 code units, not Python characters."""
return len(text.encode("utf-16-le")) // 2
@bounded_copy
async def copy_preserving_entities(message: Message, recipient_id: int, sender_name: str | None = None):
if sender_name is None:
# Native copy keeps the original body/caption and its entities unchanged.