Separate staff roles and protect message delivery with operator guides
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user