Facet detection (rich text)

atproto_client.utils.facet_detection.detect_facets(text: str) β†’ List[Main]

Detect non-@mention facets in the text: links, #tags and $cashtags.

Parameters:

text – Text to detect facets in.

Returns:

Detected facets sorted by their position in the text.

class atproto_client.utils.facet_detection.MentionMatch(handle: str, byte_start: int, byte_end: int)

Bases: NamedTuple

A mention found in the text. The handle is not resolved to a DID.

handle: str

Handle without the @.

byte_start: int

Start of the @handle in the UTF-8 encoded text (inclusive).

byte_end: int

End of the @handle in the UTF-8 encoded text (exclusive).

atproto_client.utils.facet_detection.detect_mentions(text: str) β†’ List[MentionMatch]

Detect mentions (e.g. @bsky.app) in the text.

This function doesn’t make any network requests, so handles are not resolved to DIDs and it can’t tell if they exist.

Parameters:

text – Text to detect mentions in.

Returns:

Detected mentions in the order they appear in the text.