Skip to content

Attachments

PydanticPath module-attribute

PydanticPath = Annotated[Path, _PathPydanticAnnotation]

An anyio.Path that pydantic can validate from and serialize to a plain string, for use as a field type on pydantic models.

Attachment pydantic-model

Bases: Attachment

A file attached to a received or sent message.

Fields:

  • caption (str | None)
  • content_type (str | None)
  • remote_filename (str | None)
  • height (int | None)
  • local_filename (str | None)
  • size (int | None)
  • upload_timestamp (int | None)
  • width (int | None)
  • base64_content (str | None)

local_path async

local_path() -> Path | None

Resolve where this attachment is cached on disk, if it was downloaded.

Returns:

Type Description
Path | None

The local path, or None if the attachment has no local filename.

Source code in src/signalbot/attachments/attachment.py
async def local_path(self) -> Path | None:
    """Resolve where this attachment is cached on disk, if it was downloaded.

    Returns:
        The local path, or `None` if the attachment has no local filename.
    """
    if self.local_filename is None:
        return None

    return (
        await Path.home()
        / ".local/share/signal-api/attachments"
        / self.local_filename
    )

DeleteAttachmentError

Bases: SignalAPIError

Raised when the API rejects a request to delete an attachment.

DownloadAttachmentError

Bases: SignalAPIError

Raised when downloading an attachment from the API fails.