Skip to content

Groups

GetGroupsError

Bases: SignalAPIError

Raised when fetching group data from the API fails.

GroupEntry pydantic-model

Bases: GroupEntry

A group the bot is a member of, as returned by GroupRegistry.

Fields:

GroupPermissions pydantic-model

Bases: GroupPermissions

Who is allowed to perform which actions in a group.

Fields:

GroupRegistry

GroupRegistry(signal: SignalAPI, logger: Logger)

List-like cache of the groups the bot is a member of, with lookup helpers.

To update a group's metadata, use actions (bot.groups.actions) instead.

Source code in src/signalbot/groups/registry.py
def __init__(self, signal: SignalAPI, logger: logging.Logger) -> None:
    self._signal = signal
    self._logger = logger

    self._by_id: dict[str, GroupEntry] = {}
    self._by_internal_id: dict[str, GroupEntry] = {}
    self._by_name: defaultdict[str, list[GroupEntry]] = defaultdict(list)

actions instance-attribute

actions: GroupActions

Update group metadata. Set by SignalBot._init_actions().

get

get(internal_id: str) -> GroupEntry | None

Look up a cached group by its internal id, without hitting the network.

Parameters:

Name Type Description Default
internal_id str

The group's internal id, as used by __iter__, __getitem__, and refresh()/refresh_one().

required

Returns:

Type Description
GroupEntry | None

The cached GroupEntry, or None if it isn't in the cache.

Source code in src/signalbot/groups/registry.py
def get(self, internal_id: str) -> GroupEntry | None:
    """Look up a cached group by its internal id, without hitting the network.

    Args:
        internal_id: The group's internal id, as used by `__iter__`,
            `__getitem__`, and `refresh()`/`refresh_one()`.

    Returns:
        The cached `GroupEntry`, or `None` if it isn't in the cache.
    """
    if internal_id in self._by_internal_id:
        return copy.deepcopy(self._by_internal_id[internal_id])
    return None

get_id

get_id(internal_id: str) -> str | None

Look up a group's canonical id by its internal id, without copying the full GroupEntry. For hot-path callers (e.g. per-message, per-handler dispatch checks) that only need the id.

Parameters:

Name Type Description Default
internal_id str

The group's internal id.

required

Returns:

Type Description
str | None

The group's canonical id, or None if it isn't in the cache.

Source code in src/signalbot/groups/registry.py
def get_id(self, internal_id: str) -> str | None:
    """Look up a group's canonical id by its internal id, without copying
    the full `GroupEntry`. For hot-path callers (e.g. per-message,
    per-handler dispatch checks) that only need the id.

    Args:
        internal_id: The group's internal id.

    Returns:
        The group's canonical id, or `None` if it isn't in the cache.
    """
    group = self._by_internal_id.get(internal_id)
    return group.id if group is not None else None

GroupUpdate pydantic-model

Bases: BaseMessage

Notification that a group's metadata (name, members, ...) was updated.

Fields:

  • server_delivered_timestamp (int)
  • server_received_timestamp (int)
  • source (str | None)
  • source_device (int | None)
  • source_name (str | None)
  • source_number (str | None)
  • source_uuid (str | None)
  • timestamp (int)
  • group_info (GroupUpdateInfo)

GroupUpdateInfo pydantic-model

Bases: BaseModel

The group metadata attached to a group-update event.

Fields:

UpdateGroup pydantic-model

Bases: BaseModel

The fields to change on a group. If a field is None, it is left unchanged.

Fields:

avatar pydantic-field

avatar: PydanticPath | str | None = None

The new avatar of the group. This can be a Path or a base64 encoded string of the image content.

description pydantic-field

description: str | None = None

The new description of the group.

expiration_in_seconds pydantic-field

expiration_in_seconds: int | None = None

The new expiration time of the group in seconds.

group_link: GroupLink | None = None

Enable or disable joining the group via group link.

name pydantic-field

name: str | None = None

The new name of the group.

permissions pydantic-field

permissions: GroupPermissions | None = None

The new permissions for the group.

UpdateGroupError

Bases: SignalAPIError

Raised when the API rejects a group metadata update.

AddMembers

Bases: StrEnum

EditGroup

Bases: StrEnum

Bases: StrEnum

SendMessages

Bases: StrEnum