24 lines
670 B
Python
24 lines
670 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
from .cards import is_post_format_requested
|
||
|
|
|
||
|
|
|
||
|
|
def format_outbound(
|
||
|
|
content: str,
|
||
|
|
chat_type: str = "private",
|
||
|
|
metadata: dict[str, Any] | None = None,
|
||
|
|
) -> dict[str, Any]:
|
||
|
|
meta = metadata or {}
|
||
|
|
return {
|
||
|
|
"content": content,
|
||
|
|
"chat_type": chat_type,
|
||
|
|
"thread_id": meta.get("thread_id"),
|
||
|
|
"buttons": meta.get("buttons", []),
|
||
|
|
"url_unfurl": meta.get("url_unfurl"),
|
||
|
|
"template": meta.get("template", meta.get("card_template")),
|
||
|
|
"tone": meta.get("tone", meta.get("card_tone")),
|
||
|
|
"use_post_format": is_post_format_requested(metadata),
|
||
|
|
}
|