Skip to content

Chat

Chat(api, subsonic)

Class that contains all the methods needed to interact with the chat endpoints in the Subsonic API.

Source code in .venv/lib/python3.11/site-packages/knuckles/_chat.py
def __init__(self, api: Api, subsonic: "Subsonic") -> None:
    self.api = api
    self.subsonic = subsonic

add_chat_message(message)

Add chat message.

Parameters:

Name Type Description Default
message str

The message content to add.

required

Returns:

Type Description
Subsonic

The Subsonic object where this method was called to allow method chaining.

Source code in .venv/lib/python3.11/site-packages/knuckles/_chat.py
def add_chat_message(self, message: str) -> "Subsonic":
    """Add chat message.

    Args:
        message: The message content to add.

    Returns:
        The Subsonic object where this method was called to allow
            method chaining.
    """
    self.api.json_request("addChatMessage", {"message": message})

    return self.subsonic

get_chat_messages()

Get all send chat messages.

Returns:

Type Description
list[ChatMessage]

A list with all the messages info.

Source code in .venv/lib/python3.11/site-packages/knuckles/_chat.py
def get_chat_messages(self) -> list[ChatMessage]:
    """Get all send chat messages.

    Returns:
        A list with all the messages info.
    """

    response: list[dict[str, Any]] = self.api.json_request("getChatMessages")[
        "chatMessages"
    ]["chatMessage"]

    messages = [ChatMessage(self.subsonic, **message) for message in response]

    return messages