intra_max_chatbot/bot/send_helper.py
2026-03-26 00:54:10 +03:00

23 lines
615 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Обёртка над 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,
)