"""Обёртка над bot.send_message с автоматическим логированием исходящих."""
from database.queries.message_log import log_message


async def bot_send(
    bot,
    *,
    chat_id: int,
    user_id: int | None,
    text: str,
    attachments=None,
) -> None:
    kw: dict = {"chat_id": chat_id, "text": text}
    if attachments is not None:
        kw["attachments"] = attachments
    await bot.send_message(**kw)
    await log_message(
        direction="out",
        max_user_id=user_id,
        max_chat_id=chat_id,
        message_id=None,
        text=text,
    )
