GitHub

chat_thread

API reference for chat_thread.

Addresses for chat threads (Effect's effect/chat/ChatThread).

A ChatThread names a channel, a thread or a direct conversation on one platform. The address does not say which of the three it is: MessageCreated.kind and Chat.get_thread do. The id is opaque to the core and owned by the platform's adapter: Slack's is {team}/{channel} or {team}/{channel}/{thread_ts}.

Values

AttributeTypeDescription
FROM_STRINGS.DecodeToSchema[ChatThread, str]

Decodes a {platform}:{id} string into a ChatThread and encodes it back. The string format is frozen.

Classes

Functions

make

make(platform, id) -> ChatThread

The address id on platform.

ParameterTypeDescription
platformstr
idstr

Returns ChatThread

def make(platform: str, id: str) -> ChatThread:
    """The address ``id`` on ``platform``."""
    return ChatThread(platform=platform, id=id)

equals

equals(self, that) -> bool

Whether two addresses name the same platform and id.

ParameterTypeDescription
selfChatThread
thatChatThread

Returns bool

def equals(self: ChatThread, that: ChatThread) -> bool:
    """Whether two addresses name the same platform and id."""
    return self.platform == that.platform and self.id == that.id

to_string

to_string(thread) -> str

{platform}:{id}, for session keys, entity ids and URLs. The format is frozen, because consumers persist it.

ParameterTypeDescription
threadChatThread

Returns str

def to_string(thread: ChatThread) -> str:
    """``{platform}:{id}``, for session keys, entity ids and URLs. The format
    is frozen, because consumers persist it."""
    return f"{thread.platform}:{thread.id}"

from_string

from_string(value) -> ChatThread | None

The address a {platform}:{id} string names: the platform is everything before the first :, so an id may hold :. None when either part is empty.

ParameterTypeDescription
valuestr

Returns ChatThread | None

def from_string(value: str) -> ChatThread | None:
    """The address a ``{platform}:{id}`` string names: the platform is
    everything before the first ``:``, so an id may hold ``:``. ``None``
    when either part is empty."""
    index = value.find(":")
    if index <= 0 or index == len(value) - 1:
        return None
    return make(value[:index], value[index + 1 :])