GitHub

API reference for Ops.

The operations of one platform; Chat has the same ops, routed by thread.platform.

  • post takes standard Markdown that must fit limits.message_length: it never splits or truncates, and fails TooLarge without calling the platform. Mentions notify nobody, and no link preview shows unless the adapter's scoped options ask.
  • fetch_message fails NotFound for a message that is gone.
  • history pages lazily: "backward" runs newest to oldest, "forward" oldest to newest, and from_ is exclusive. A thread's oldest message is its opener, the one message not addressed to the thread.
  • download fails TooLarge as soon as more than max_bytes arrive, and streams.
  • start_thread is get-or-create: the thread under message_id.
  • opener is the message a thread hangs off; None for a channel or direct address, or when it was deleted.
  • actions are a flat list of elements beside the Markdown. An edit replaces the whole message, so one without actions removes them.
  • follow_up sends the answer a command's Defer promised. It is never retried, takes no files, and fails NotFound with detail interaction_expired past limits.follow_up_age.

Functions

post

post(thread, *, markdown, reply_to=None, files=(), actions=()) -> Effect[Posted, ChatError]
ParameterTypeDescription
threadChatThread
markdownstr
reply_toReplyTo | None = None
filesSequence[File] = ()
actionsSequence[Action] = ()

Returns Effect[Posted, ChatError]

def post(
    self,
    thread: ChatThread,
    *,
    markdown: str,
    reply_to: ReplyTo | None = None,
    files: Sequence[File] = (),
    actions: Sequence[Action] = (),
) -> Effect[Posted, ChatError]: ...

edit

edit(thread, message_id, *, markdown, actions=()) -> Effect[None, ChatError]
ParameterTypeDescription
threadChatThread
message_idstr
markdownstr
actionsSequence[Action] = ()

Returns Effect[None, ChatError]

def edit(
    self, thread: ChatThread, message_id: str, *, markdown: str, actions: Sequence[Action] = ()
) -> Effect[None, ChatError]: ...

delete

delete(thread, message_id) -> Effect[None, ChatError]
ParameterTypeDescription
threadChatThread
message_idstr

Returns Effect[None, ChatError]

def delete(self, thread: ChatThread, message_id: str) -> Effect[None, ChatError]: ...

fetch_message

fetch_message(thread, message_id) -> Effect[ChatMessage, ChatError]
ParameterTypeDescription
threadChatThread
message_idstr

Returns Effect[ChatMessage, ChatError]

def fetch_message(
    self, thread: ChatThread, message_id: str
) -> Effect[ChatMessage, ChatError]: ...

history

history(thread, *, direction, from_=None) -> Stream[ChatMessage, ChatError]
ParameterTypeDescription
threadChatThread
directionDirection
from_str | None = None

Returns Stream[ChatMessage, ChatError]

def history(
    self, thread: ChatThread, *, direction: Direction, from_: str | None = None
) -> Stream[ChatMessage, ChatError]: ...

download

download(thread, attachment, *, max_bytes) -> Stream[bytes, ChatError]
ParameterTypeDescription
threadChatThread
attachmentAttachment
max_bytesint

Returns Stream[bytes, ChatError]

def download(
    self, thread: ChatThread, attachment: Attachment, *, max_bytes: int
) -> Stream[bytes, ChatError]: ...

start_thread

start_thread(thread, message_id, *, name=None) -> Effect[ChatThread, ChatError]
ParameterTypeDescription
threadChatThread
message_idstr
namestr | None = None

Returns Effect[ChatThread, ChatError]

def start_thread(
    self, thread: ChatThread, message_id: str, *, name: str | None = None
) -> Effect[ChatThread, ChatError]: ...

get_thread

get_thread(thread) -> Effect[ThreadInfo, ChatError]
ParameterTypeDescription
threadChatThread

Returns Effect[ThreadInfo, ChatError]

def get_thread(self, thread: ChatThread) -> Effect[ThreadInfo, ChatError]: ...

opener

opener(thread) -> Effect[ChatMessage | None, ChatError]
ParameterTypeDescription
threadChatThread

Returns Effect[ChatMessage | None, ChatError]

def opener(self, thread: ChatThread) -> Effect[ChatMessage | None, ChatError]: ...

get_user

get_user(id, *, in_=None) -> Effect[User, ChatError]
ParameterTypeDescription
idstr
in_ChatThread | None = None

Returns Effect[User, ChatError]

def get_user(self, id: str, *, in_: ChatThread | None = None) -> Effect[User, ChatError]: ...

follow_up

follow_up(deferred, *, markdown, actions=()) -> Effect[None, ChatError]
ParameterTypeDescription
deferredDefer
markdownstr
actionsSequence[Action] = ()

Returns Effect[None, ChatError]

def follow_up(
    self, deferred: Defer, *, markdown: str, actions: Sequence[Action] = ()
) -> Effect[None, ChatError]: ...