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#
| Attribute | Type | Description |
|---|---|---|
FROM_STRING | S.DecodeToSchema[ChatThread, str] | Decodes a |
Classes#
Functions#
make#
make(platform, id) -> ChatThreadThe address id on platform.
| Parameter | Type | Description |
|---|---|---|
platform | str | |
id | str |
Returns ChatThread
def make(platform: str, id: str) -> ChatThread:
"""The address ``id`` on ``platform``."""
return ChatThread(platform=platform, id=id)equals#
equals(self, that) -> boolWhether two addresses name the same platform and id.
| Parameter | Type | Description |
|---|---|---|
self | ChatThread | |
that | ChatThread |
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.idto_string#
to_string(thread) -> str{platform}:{id}, for session keys, entity ids and URLs. The format
is frozen, because consumers persist it.
| Parameter | Type | Description |
|---|---|---|
thread | ChatThread |
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 | NoneThe address a {platform}:{id} string names: the platform is
everything before the first :, so an id may hold :. None
when either part is empty.
| Parameter | Type | Description |
|---|---|---|
value | str |
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 :])