### SQLiteDatabase.start Source: https://github.com/mautrix/python/blob/master/docs/index.md Starts the SQLite database connection. ```APIDOC ## SQLiteDatabase.start ### Description Starts the SQLite database connection. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### PostgresDatabase.start Source: https://github.com/mautrix/python/blob/master/docs/index.md Starts the PostgreSQL database connection pool. ```APIDOC ## PostgresDatabase.start ### Description Starts the PostgreSQL database connection pool. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### Async Interpreter Example Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.util/manhole.md Demonstrates how to send output or values back to the client in an asynchronous interpreter. This is useful for displaying results of executed commands. ```python >>> 5 5 >>> print('cash rules everything around me') cash rules everything around me ``` -------------------------------- ### Initialize ClientAPI and get user info Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Initializes a ClientAPI instance with user ID, base URL, and token. Then, it demonstrates fetching the current user's information using the whoami() method and retrieving a list of joined room IDs. ```python >>> from mautrix.client import ClientAPI >>> client = ClientAPI("@user:matrix.org", base_url="https://matrix-client.matrix-org", token="syt_123_456") >>> await client.whoami() WhoamiResponse(user_id="@user:matrix.org", device_id="DEV123") >>> await client.get_joined_rooms() ["!roomid:matrix.org"] ``` -------------------------------- ### StatefulCommandCompiler.buf Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the command buffer. ```APIDOC ## StatefulCommandCompiler.buf ### Description Gets the command buffer. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### mautrix.util.manhole.start_manhole Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.util/manhole.md Starts a manhole server on a given UNIX address. ```APIDOC ## mautrix.util.manhole.start_manhole(path: str, banner: str = '', namespace: Dict[str, Any] | None = None, loop: AbstractEventLoop | None = None, whitelist: Set[int] | None = None) -> Tuple[AbstractServer, Callable[[], None]] ### Description Starts a manhole server on a given UNIX address. ### Parameters #### Path Parameters - **path** (str) - The path to create the UNIX socket at. - **banner** (str) - Optional. The banner to show when clients connect. - **namespace** (Dict[str, Any] | None) - Optional. The globals to provide to connected clients. - **loop** (AbstractEventLoop | None) - Optional. The asyncio event loop to use. - **whitelist** (Set[int] | None) - Optional. List of user IDs to allow connecting. ``` -------------------------------- ### Manage Matrix Rooms with ClientAPI Source: https://context7.com/mautrix/python/llms.txt Use ClientAPI to create, join, invite, kick, set state, and leave Matrix rooms. Ensure you have a valid API token and client setup. ```python import asyncio from mautrix.api import HTTPAPI from mautrix.client import ClientAPI from mautrix.types import ( RoomCreatePreset, RoomDirectoryVisibility, EventType, PowerLevelStateEventContent, ) async def main(): api = HTTPAPI(base_url="https://matrix.example.org", token="syt_token") client = ClientAPI(mxid="@bot:example.org", api=api) # Create a private room room_id = await client.create_room( alias_localpart="my-bot-room", name="My Bot Room", topic="A room managed by my bot", preset=RoomCreatePreset.PRIVATE, visibility=RoomDirectoryVisibility.PRIVATE, invitees=["@alice:example.org"], ) print(room_id) # !abc123:example.org # Join a room joined_room = await client.join_room("!other:example.org") print(joined_room) # Invite a user await client.invite_user(room_id, "@bob:example.org") # Kick a user with a reason await client.kick_user(room_id, "@spammer:example.org", reason="Spamming") # Set room name and topic await client.send_state_event( room_id, EventType.ROOM_NAME, {"name": "Renamed Room"} ) # Adjust power levels levels = PowerLevelStateEventContent( users={"@admin:example.org": 100, "@bot:example.org": 50}, events_default=0, state_default=50, ) await client.send_state_event(room_id, EventType.ROOM_POWER_LEVELS, levels) # Leave a room await client.leave_room(room_id) asyncio.run(main()) ``` -------------------------------- ### AppService Methods Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.appservice/index.md Provides methods for interacting with the application service, including starting and stopping the server, and pinging the homeserver. ```APIDOC ## ping_self(txn_id: str | None = None) -> int ### Description Pings the homeserver to check connectivity. ### Parameters: * **txn_id** (str | None) - Optional transaction ID. ### Return type: int - The response code from the homeserver. ## start(host: str = '127.0.0.1', port: int = 8080) ### Description Starts the application service server. ### Parameters: * **host** (str) - The host to bind to. * **port** (int) - The port to bind to. ### Return type: None ## stop() ### Description Stops the application service server. ### Return type: None ``` -------------------------------- ### start_manhole Source: https://github.com/mautrix/python/blob/master/docs/index.md Starts the manhole service, allowing for remote debugging and interaction. ```APIDOC ## start_manhole() ### Description Starts the manhole service, allowing for remote debugging and interaction. ### Usage This function is typically called to initialize and run the manhole server. ``` -------------------------------- ### Database Migrations and Operations with mautrix.db Source: https://context7.com/mautrix/python/llms.txt Demonstrates defining database migrations and performing basic CRUD operations using mautrix.db with SQLite and PostgreSQL. Ensure the appropriate database driver (aiosqlite or asyncpg) is installed. ```python from mautrix.db import Database, UpgradeTable import asyncio upgrade_table = UpgradeTable() @upgrade_table.register(description="Create messages table") async def upgrade_v1(conn, scheme) -> None: await conn.execute(""" CREATE TABLE messages ( event_id TEXT PRIMARY KEY, room_id TEXT NOT NULL, sender TEXT NOT NULL, body TEXT NOT NULL, ts BIGINT NOT NULL ) """) @upgrade_table.register(description="Add index on room_id") async def upgrade_v2(conn, scheme) -> None: await conn.execute("CREATE INDEX messages_room_idx ON messages (room_id)") async def main(): # SQLite (requires aiosqlite) db = Database.create( "sqlite:///bridge.db", upgrade_table=upgrade_table, owner_name="my-bridge", ) await db.start() # runs pending migrations automatically # Insert a row await db.execute( "INSERT INTO messages (event_id, room_id, sender, body, ts) VALUES ($1,$2,$3,$4,$5)", "$evt:example.org", "!room:example.org", "@alice:example.org", "Hello", 1700000000000 ) # Fetch rows rows = await db.fetch("SELECT * FROM messages WHERE room_id=$1", "!room:example.org") for row in rows: print(dict(row)) # Fetch a single value count = await db.fetchval("SELECT COUNT(*) FROM messages") print("Total messages:", count) await db.stop() # PostgreSQL (requires asyncpg) pg_db = Database.create( "postgresql://user:pass@localhost/mybridge", upgrade_table=upgrade_table, owner_name="my-bridge", ignore_foreign_tables=False, ) await pg_db.start() await pg_db.stop() asyncio.run(main()) ``` -------------------------------- ### Manage User Profiles with ClientAPI Source: https://context7.com/mautrix/python/llms.txt Use ClientAPI to set and get user display names and avatar URLs, and to search for users. Requires a configured ClientAPI instance. ```python import asyncio from mautrix.api import HTTPAPI from mautrix.client import ClientAPI async def main(): api = HTTPAPI(base_url="https://matrix.example.org", token="syt_token") client = ClientAPI(mxid="@bot:example.org", api=api) # Set display name (no-ops if already set to same value) await client.set_displayname("My Cool Bot") # Get another user's display name name = await client.get_displayname("@alice:example.org") print(name) # Alice # Set avatar from an uploaded MXC URI await client.set_avatar_url("mxc://example.org/avatar123") # Get another user's full profile profile = await client.get_profile("@alice:example.org") print(profile.displayname, profile.avatar_url) # Search users by display name or MXID results = await client.search_users("alice", limit=5) for user in results.results: print(user.user_id, user.display_name) print("Limited?", results.limited) # True if more results exist asyncio.run(main()) ``` -------------------------------- ### join_room Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.mixins.md Allows a user to start participating in a room by providing its ID or alias. Optionally, a list of servers can be provided to help discover the room ID, and a third-party signature can be included to prove identity. ```APIDOC ## join_room ### Description Start participating in a room, i.e. join it by its ID or alias, with an optional list of servers to ask about the ID from. ### Method `join_room(room_id_or_alias, servers=None, third_party_signed=None, max_retries=4)` ### Parameters #### Path Parameters * **room_id_or_alias** (RoomID | RoomAlias) - Required - The ID of the room to join, or an alias pointing to the room. #### Query Parameters * **servers** (list[str] | None) - Optional - A list of servers to ask about the room ID to join. Not applicable for aliases, as aliases already contain the necessary server information. * **third_party_signed** (JSON) - Optional - A signature of an `m.third_party_invite` token to prove that this user owns a third party identity which has been invited to the room. * **max_retries** (int) - Optional - The maximum number of retries. Used to circumvent a Synapse bug with accepting invites over federation. 0 means only one join call will be attempted. ### Returns The ID of the room the user joined. ### Return type RoomID ``` -------------------------------- ### Reading Room History and State with EventMethods Source: https://context7.com/mautrix/python/llms.txt Fetch events, paginate message history, read room state, and get member lists using EventMethods. Use PaginationDirection.BACKWARD for history and get_joined_members for efficient member retrieval. ```python import asyncio from mautrix.api import HTTPAPI from mautrix.client import ClientAPI from mautrix.types import PaginationDirection, Membership async def main(): api = HTTPAPI(base_url="https://matrix.example.org", token="syt_token") client = ClientAPI(mxid="@bot:example.org", api=api) room = "!room:example.org" # Fetch a single event event = await client.get_event(room, "$abc:example.org") print(event.type, event.sender) # Paginate backwards through history (newest 50 messages) page = await client.get_messages( room, direction=PaginationDirection.BACKWARD, limit=50, ) for evt in page.events: print(evt.event_id, evt.sender) # page.end is the token for the next page next_page = await client.get_messages( room, direction=PaginationDirection.BACKWARD, from_token=page.end, limit=50, ) # Get all current state events state_events = await client.get_state(room) print(len(state_events), "state events") # Get joined members only members = await client.get_joined_members(room) for user_id, member in members.items(): print(user_id, member.displayname) # Get members filtered by membership invited = await client.get_members(room, membership=Membership.INVITE) print([e.state_key for e in invited]) asyncio.run(main()) ``` -------------------------------- ### Custom Serializer Example Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.types.md Example of defining a custom serializer for `datetime` objects using the `@serializer` decorator. ```APIDOC ## Custom Serializer Example ### Description This example shows how to define a custom serializer for Python's `datetime` object. The `@serializer` decorator from `mautrix.types` is used to register the `serialize_datetime` function for converting `datetime` objects into a JSON-serializable format (a timestamp in this case). ### Usage ```python from datetime import datetime from mautrix.types import serializer, JSON @serializer(datetime) def serialize_datetime(dt: datetime) -> JSON: return dt.timestamp() ``` ### Parameters - `dt` (datetime): The `datetime` object to serialize. ``` -------------------------------- ### StatefulCommandCompiler.__init__ Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the StatefulCommandCompiler. ```APIDOC ## StatefulCommandCompiler.__init__() ### Description Initializes the StatefulCommandCompiler. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### Custom Deserializer Example Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.types.md Example of defining a custom deserializer for `datetime` objects using the `@deserializer` decorator. ```APIDOC ## Custom Deserializer Example ### Description This example demonstrates how to create a custom deserializer for Python's `datetime` object. It uses the `@deserializer` decorator provided by `mautrix.types` to register the `deserialize_datetime` function for handling `datetime` types during deserialization. ### Usage ```python from datetime import datetime from mautrix.types import deserializer, JSON @deserializer(datetime) def deserialize_datetime(data: JSON) -> datetime: return datetime.fromtimestamp(data) ``` ### Parameters - `data` (JSON): The input data to deserialize into a `datetime` object. ``` -------------------------------- ### Get User Intent API Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.appservice/intent.md Get the intent API for a specific user. This is just a proxy to AppServiceAPI.intent(). You should only call this method for the bot user. Calling it with child intent APIs will result in a warning log. ```APIDOC ## GET /_matrix/app/v1/intent/:user_id ### Description Get the intent API for a specific user. ### Method GET ### Endpoint /intent/:user_id ### Parameters #### Path Parameters - **user_id** (UserID) - Required - The Matrix ID of the user whose intent API to get. #### Query Parameters - **token** (str | None) - Optional - The access token to use for the Matrix ID. - **base_url** (str | None) - Optional - An optional URL to use for API requests. - **as_token** (bool) - Optional - Whether the provided token is actually another as_token (meaning the `user_id` query parameter needs to be used). ``` -------------------------------- ### __init__ Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Initializes a ClientAPI instance. It requires either an existing HTTPAPI instance or parameters to create one. ```APIDOC ## __init__ ### Description Initialize a ClientAPI. You must either provide the `api` parameter with an existing [`mautrix.api.HTTPAPI`](mautrix.api.md#mautrix.api.HTTPAPI) instance, or provide the `base_url` and other arguments for creating it as kwargs. ### Parameters #### Path Parameters * **mxid** (*UserID*) – The Matrix ID of the user. This is used for things like setting profile metadata. Additionally, the homeserver domain is extracted from this string and used for setting aliases and such. This can be changed later using set_mxid. * **device_id** (*DeviceID*) – The device ID corresponding to the access token used. * **api** (*HTTPAPI | None*) – The [`mautrix.api.HTTPAPI`](mautrix.api.md#mautrix.api.HTTPAPI) instance to use. You can also pass the `kwargs` to create a HTTPAPI instance rather than creating the instance yourself. * **kwargs** – If `api` is not specified, then the arguments to pass when creating a HTTPAPI. ### Return type None ``` -------------------------------- ### Implement a Matrix Bridge with Bridge Base Class Source: https://context7.com/mautrix/python/llms.txt Subclass Bridge to create a full Matrix bridge. Implement abstract methods for user, portal, and puppet retrieval. This example sets up a basic bridge structure with database upgrade logic. ```python import asyncio from mautrix.bridge import Bridge from mautrix.appservice import AppService from mautrix.util.async_db import UpgradeTable, Database from mautrix.types import UserID, RoomID upgrade_table = UpgradeTable() @upgrade_table.register(description="Initial schema") async def upgrade_v1(conn, scheme) -> None: await conn.execute(""" CREATE TABLE IF NOT EXISTS users ( mxid TEXT PRIMARY KEY, remote_id TEXT ) """) class MyBridge(Bridge): name = "my-bridge" command = "python -m my_bridge" description = "My example bridge" repo_url = "https://github.com/example/my-bridge" markdown_version = "0.1.0" version = "0.1.0" upgrade_table = upgrade_table # These abstract methods MUST be implemented: async def get_user(self, user_id: UserID, create: bool = True): return None # Look up from DB in real implementation async def get_portal(self, room_id: RoomID): return None async def get_puppet(self, user_id: UserID, create: bool = False): return None async def get_double_puppet(self, user_id: UserID): return None def is_bridge_ghost(self, user_id: UserID) -> bool: return user_id.startswith("@_mybridge_") async def count_logged_in_users(self) -> int: return await self.db.fetchval("SELECT COUNT(*) FROM users WHERE remote_id IS NOT NULL") # Entry point — reads config.yaml, generates registration if -g passed if __name__ == "__main__": MyBridge().run() # Usage: # python bridge.py -c config.yaml # run bridge # python bridge.py -c config.yaml -g -r reg.yaml # generate registration ``` -------------------------------- ### AsyncInterpreter.writer Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the asynchronous writer. ```APIDOC ## AsyncInterpreter.writer ### Description Gets the asynchronous writer. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### Set up Matrix AppService with aiohttp Source: https://context7.com/mautrix/python/llms.txt Configure and run an AppService using mautrix to receive Matrix transactions and manage virtual users. Requires registration file tokens and a running homeserver. ```python import asyncio from mautrix.appservice import AppService from mautrix.types import EventType, StateEvent async def main(): appservice = AppService( server="https://matrix.example.org", domain="example.org", as_token="appservice_token_from_registration", hs_token="homeserver_token_from_registration", bot_localpart="mybridge", id="mybridge", ephemeral_events=True, log="mybridge.as", ) # Register a Matrix event handler @appservice.matrix_event_handler async def handle_event(event: StateEvent) -> None: print(f"Received: {event.type} in {event.room_id}") # Start listening on 127.0.0.1:29318 await appservice.start(host="127.0.0.1", port=29318) # The bot intent is available after start() bot = appservice.intent rooms = await bot.get_joined_rooms() print("Bot is in rooms:", rooms) # Mark the bridge as ready (enables readiness probe) appservice.ready = True await asyncio.sleep(3600) await appservice.stop() asyncio.run(main()) ``` -------------------------------- ### FileStateStore.__init__ Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.state_store/file.md Initializes a new FileStateStore instance. This constructor sets up the file-based state storage, allowing for persistence of client state. ```APIDOC ## __init__ ### Description Initializes a new FileStateStore instance. ### Parameters * **path** (*str* | *Path* | *IO*) - The path or file-like object to store the state in. * **filer** ([*Filer*](../mautrix.util/file_store.md#mautrix.util.file_store.Filer) | None) - An optional Filer object for custom file handling. * **binary** (*bool*) - Whether to store the state in binary format. Defaults to True. * **save_interval** (*float*) - The interval in seconds at which to automatically save the state. Defaults to 60.0. ### Return type None ``` -------------------------------- ### AsyncInterpreter.reader Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the asynchronous reader. ```APIDOC ## AsyncInterpreter.reader ### Description Gets the asynchronous reader. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### PgStateStore.__init__ Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.state_store/asyncpg.md Initializes the PgStateStore with a database connection. ```APIDOC ## __init__(db) ### Description Initializes the PgStateStore with a database connection. ### Parameters * **db** (Database) - The asynchronous database connection object. ``` -------------------------------- ### TraceLogger.getChild Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets a child logger. ```APIDOC ## TraceLogger.getChild() ### Description Gets a child logger. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### Client Initialization and Properties Source: https://github.com/mautrix/python/blob/master/docs/index.md Details on initializing the Client and accessing its core properties. ```APIDOC ## Client Class ### `Client.__init__()` Initializes a new Matrix client instance. ### `Client.crypto` (property) Provides access to the client's encryption functionalities. ``` -------------------------------- ### AsyncInterpreter.compiler Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the interpreter's compiler. ```APIDOC ## AsyncInterpreter.compiler ### Description Gets the interpreter's compiler. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### AsyncInterpreter.banner Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the interpreter's banner. ```APIDOC ## AsyncInterpreter.banner ### Description Gets the interpreter's banner. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### open Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.state_store/index.md Opens the state store, preparing it for use. ```APIDOC ## open() ### Description Opens the state store. ### Return type None ``` -------------------------------- ### AppServiceServerMixin.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the AppServiceServerMixin, setting up handlers and configurations for the Matrix server interaction. ```APIDOC ## AppServiceServerMixin.__init__() ### Description Initializes the AppServiceServerMixin. ### Method Not specified (constructor) ### Endpoint Not applicable (constructor) ``` -------------------------------- ### AsyncInterpreter.namespace Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the interpreter's namespace. ```APIDOC ## AsyncInterpreter.namespace ### Description Gets the interpreter's namespace. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### get_presence Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Get the presence info of a user. ```APIDOC ## async get_presence(user_id) ### Description Get the presence info of a user. See also: [API reference](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-presence-list-userid) ### Parameters #### Path Parameters - **user_id** ([*UserID*](mautrix.types.md#mautrix.types.UserID)) – The ID of the user whose presence info to get. ### Returns The presence info of the given user. ### Return type [*PresenceEventContent*](mautrix.types.md#mautrix.types.PresenceEventContent) ``` -------------------------------- ### BaseProxyConfig.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the BaseProxyConfig. This class is used for proxy configurations. ```APIDOC ## BaseProxyConfig.__init__() ### Description Initializes a new instance of BaseProxyConfig, which is designed for managing proxy-related configuration settings. ### Method (Not specified in source, typically a method call in Python) ### Endpoint (Not applicable for Python methods) ### Parameters (Parameters not specified in source) ### Request Example (Not applicable for Python methods) ### Response (Response details not specified in source) ``` -------------------------------- ### user Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.appservice/api.md Get the AppServiceAPI for an appservice-managed user. ```APIDOC ## user(user) ### Description Get the AppServiceAPI for an appservice-managed user. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **user** (UserID) - The Matrix user ID of the user whose AppServiceAPI to get. ### Request Example ```python # Example usage (assuming you have an AppServiceAPI instance named 'appservice') child_appservice = appservice.user("@charlie:example.org") ``` ### Response #### Success Response (200) - **ChildAppServiceAPI** (ChildAppServiceAPI) - The ChildAppServiceAPI object for the user. #### Response Example ```python # The response is an instance of ChildAppServiceAPI, not a JSON object. # You can then use this object to make further requests for that user. # For example: # await child_appservice.request("GET", "/_matrix/client/v3/profile/@charlie:example.org") ``` ``` -------------------------------- ### mautrix.util.ffmpeg.NotInstalledError Source: https://github.com/mautrix/python/blob/master/docs/index.md Exception raised when FFmpeg is not installed. ```APIDOC ## mautrix.util.ffmpeg.NotInstalledError ### Description Exception raised when FFmpeg is not installed. ### Methods - `__init__()`: Initializes the NotInstalledError. ``` -------------------------------- ### ConfigUpdateHelper.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the ConfigUpdateHelper. This helper class is used for managing configuration updates. ```APIDOC ## ConfigUpdateHelper.__init__() ### Description Initializes a new instance of the ConfigUpdateHelper. This class assists in managing and applying configuration updates. ### Method (Not specified in source, typically a method call in Python) ### Endpoint (Not applicable for Python methods) ### Parameters (Parameters not specified in source) ### Request Example (Not applicable for Python methods) ### Response (Response details not specified in source) ``` -------------------------------- ### BaseStringConfig.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the BaseStringConfig. This class handles string-based configuration. ```APIDOC ## BaseStringConfig.__init__() ### Description Initializes a new instance of BaseStringConfig, which is designed for managing configuration values that are primarily strings. ### Method (Not specified in source, typically a method call in Python) ### Endpoint (Not applicable for Python methods) ### Parameters (Parameters not specified in source) ### Request Example (Not applicable for Python methods) ### Response (Response details not specified in source) ``` -------------------------------- ### InterpreterFactory.banner Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the interpreter factory's banner. ```APIDOC ## InterpreterFactory.banner ### Description Gets the interpreter factory's banner. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### InterpreterFactory.namespace Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the interpreter factory's namespace. ```APIDOC ## InterpreterFactory.namespace ### Description Gets the interpreter factory's namespace. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### RecursionContext.ul_depth Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the current unordered list depth. ```APIDOC ## RecursionContext.ul_depth ### Description Gets the current unordered list depth. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### PostgresDatabase.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes a PostgresDatabase object. ```APIDOC ## PostgresDatabase.__init__() ### Description Initializes a PostgresDatabase object. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### InterpreterFactory.__init__ Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the InterpreterFactory. ```APIDOC ## InterpreterFactory.__init__() ### Description Initializes the InterpreterFactory. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### ClientAPI.mxid Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets the Matrix ID of the current user. ```APIDOC ## mxid ### Description Gets the Matrix ID of the current user. ### Method GET ### Endpoint /_matrix/client/v3/account/whoami ``` -------------------------------- ### get_profile Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Get the combined profile information for a user. ```APIDOC ## async get_profile(user_id) ### Description Get the combined profile information for a user. See also: [API reference](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid) ### Parameters #### Path Parameters - **user_id** ([*UserID*](mautrix.types.md#mautrix.types.UserID)) – The ID of the user whose profile to get. ### Returns The profile information of the given user. ### Return type [*Member*](mautrix.types.md#mautrix.types.Member) ``` -------------------------------- ### Client Initialization Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.md Initializes a ClientAPI instance. You can either provide an existing HTTPAPI instance or pass arguments to create one. ```APIDOC ## Client ### Description Initializes a ClientAPI. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters: * **mxid** (str) - The Matrix ID of the user. * **device_id** (str) - The device ID corresponding to the access token used. * **api** (mautrix.api.HTTPAPI) - The HTTPAPI instance to use. If not specified, kwargs will be used to create one. * **kwargs** - Arguments to pass when creating a HTTPAPI instance if `api` is not provided. * **sync_store** (SyncStore | None) - Optional sync store. * **state_store** (StateStore | None) - Optional state store. ### Return type None ``` -------------------------------- ### AsyncInterpreter.__init__ Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the AsyncInterpreter. ```APIDOC ## AsyncInterpreter.__init__() ### Description Initializes the AsyncInterpreter. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### UnsupportedDatabaseVersion.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes an UnsupportedDatabaseVersion exception. ```APIDOC ## UnsupportedDatabaseVersion.__init__() ### Description Initializes an UnsupportedDatabaseVersion exception. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### get_account_data Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Get a specific account data event from the homeserver. ```APIDOC ## get_account_data(type, room_id=None) ### Description Get a specific account data event from the homeserver. See also: [API reference](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-account-data-type) ### Parameters #### Path Parameters * **type** (EventType | str) - Required - The type of the account data event to get. * **room_id** (RoomID | None) - Optional - Optionally, the room ID to get per-room account data. ### Returns The data in the event. ### Return type JSON ``` -------------------------------- ### BaseFileConfig.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the BaseFileConfig. This class handles configuration loading and saving from files. ```APIDOC ## BaseFileConfig.__init__() ### Description Initializes a new instance of BaseFileConfig, which is designed for managing configuration stored in files. ### Method (Not specified in source, typically a method call in Python) ### Endpoint (Not applicable for Python methods) ### Parameters (Parameters not specified in source) ### Request Example (Not applicable for Python methods) ### Response (Response details not specified in source) ``` -------------------------------- ### UpgradeTable.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes an UpgradeTable object. ```APIDOC ## UpgradeTable.__init__() ### Description Initializes an UpgradeTable object. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### mautrix.util.ffmpeg.probe_bytes Source: https://github.com/mautrix/python/blob/master/docs/index.md Probes media from bytes to get information using FFmpeg. ```APIDOC ## mautrix.util.ffmpeg.probe_bytes ### Description Probes media from bytes to get information using FFmpeg. ### Parameters - `input_bytes` (bytes): The input media bytes. - `**kwargs`: Additional arguments for FFmpeg. ``` -------------------------------- ### Interpreter.__init__ Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the Interpreter. ```APIDOC ## Interpreter.__init__() ### Description Initializes the Interpreter. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### AppServiceAPI.real_user() Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets an intent for a real user associated with the app service. ```APIDOC ## AppServiceAPI.real_user() ### Description Gets an intent for a real user associated with the app service. ### Method Not specified (likely internal or SDK method) ### Endpoint Not applicable (SDK method) ### Parameters - **user_id** (str) - Required - The ID of the real user. ``` -------------------------------- ### get_txn_id Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.api.md Get a new unique transaction ID for Matrix requests. ```APIDOC ## get_txn_id ### Description Get a new unique transaction ID. ### Method This is a utility method and does not correspond to a specific HTTP method. ### Endpoint N/A ### Parameters None ### Returns A unique transaction ID string. ### Return Type str ``` -------------------------------- ### mautrix.util.ffmpeg.probe_path Source: https://github.com/mautrix/python/blob/master/docs/index.md Probes media from a file path to get information using FFmpeg. ```APIDOC ## mautrix.util.ffmpeg.probe_path ### Description Probes media from a file path to get information using FFmpeg. ### Parameters - `input_path` (str): The path to the input media file. - `**kwargs`: Additional arguments for FFmpeg. ``` -------------------------------- ### AppServiceAPI.user() Source: https://github.com/mautrix/python/blob/master/docs/index.md Gets an intent for a user, potentially creating one if it doesn't exist. ```APIDOC ## AppServiceAPI.user() ### Description Gets an intent for a user. ### Method Not specified (likely internal or SDK method) ### Endpoint Not applicable (SDK method) ### Parameters - **user_id** (str) - Required - The ID of the user. ``` -------------------------------- ### ConfigUpdateHelper Methods Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.util/index.md Helper methods for managing configuration updates and copies. ```APIDOC ## ConfigUpdateHelper.__init__() ### Description Initializes the ConfigUpdateHelper. ### Method (Not specified, constructor) ### Endpoint N/A (Python method) ### Parameters None specified ### Request Example N/A ### Response N/A ``` ```APIDOC ## ConfigUpdateHelper.copy() ### Description Creates a copy of the configuration. ### Method (Not specified, likely an instance method) ### Endpoint N/A (Python method) ### Parameters None specified ### Request Example N/A ### Response (Not specified) ``` ```APIDOC ## ConfigUpdateHelper.copy_dict() ### Description Copies a dictionary representation of the configuration. ### Method (Not specified, likely an instance method) ### Endpoint N/A (Python method) ### Parameters None specified ### Request Example N/A ### Response (Not specified) ``` -------------------------------- ### ColorFormatter.__init__ Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes the ColorFormatter. ```APIDOC ## ColorFormatter.__init__() ### Description Initializes the ColorFormatter. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response (No response specified in source) ``` -------------------------------- ### Parse matrix.to URL to get UserID Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.types.md Parse a matrix.to URL and extract the UserID from it. ```python >>> from mautrix.types import MatrixURI >>> MatrixURI.parse("https://matrix.to/#/@user:example.com").user_id '@user:example.com' ``` -------------------------------- ### get_members Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Get the list of members for a room. This method allows filtering members by membership status. ```APIDOC ## async get_members(room_id, at=None, membership=None, not_membership=None) ### Description Get the list of members for a room. See also: [API reference](https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidmembers) ### Parameters #### Path Parameters - **room_id** ([*RoomID*](mautrix.types.md#mautrix.types.RoomID)) – The ID of the room to get the member events for. #### Query Parameters - **at** ([*SyncToken*](mautrix.types.md#mautrix.types.SyncToken) *|* *None*) – The point in time (pagination token) to return members for in the room. This token can be obtained from a `prev_batch` token returned for each room by the sync API. Defaults to the current state of the room, as determined by the server. - **membership** ([*Membership*](mautrix.types.md#mautrix.types.Membership) *|* *None*) – The kind of membership to filter for. Defaults to no filtering if unspecified. When specified alongside `not_membership`, the two parameters create an ‘or’ condition: either the `membership` is the same as membership or is not the same as `not_membership`. - **not_membership** ([*Membership*](mautrix.types.md#mautrix.types.Membership) *|* *None*) – The kind of membership to exclude from the results. Defaults to no filtering if unspecified. ### Returns A list of most recent member events for each user. ### Return type list[[*StateEvent*](mautrix.types.md#mautrix.types.StateEvent)] ``` -------------------------------- ### MemoryStateStore.__init__() Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.state_store/memory.md Initializes a new instance of the MemoryStateStore class. ```APIDOC ## MemoryStateStore.__init__() ### Description Initializes a new instance of the MemoryStateStore class. ### Method __init__ ### Parameters None ### Response Type None ``` -------------------------------- ### DatabaseNotOwned.__init__() Source: https://github.com/mautrix/python/blob/master/docs/index.md Initializes a DatabaseNotOwned exception. ```APIDOC ## DatabaseNotOwned.__init__() ### Description Initializes a DatabaseNotOwned exception. ### Method (Not specified in source) ### Endpoint (Not specified in source) ### Parameters (Not specified in source) ### Request Example (Not specified in source) ### Response #### Success Response (200) (Not specified in source) #### Response Example (Not specified in source) ``` -------------------------------- ### AppService.loop Source: https://github.com/mautrix/python/blob/master/docs/index.md Starts or manages the main event loop for the app service. This is a core operational method. ```APIDOC ## AppService.loop ### Description Manages the main event loop for the app service. ### Method Not specified (likely internal or SDK method) ### Endpoint Not applicable (SDK method) ``` -------------------------------- ### ConfigUpdateHelper.copy() Source: https://github.com/mautrix/python/blob/master/docs/index.md Creates a copy of the configuration managed by the helper. This is useful for creating independent configuration states. ```APIDOC ## ConfigUpdateHelper.copy() ### Description Creates and returns a copy of the configuration managed by this helper. This allows for creating independent snapshots of the configuration state. ### Method (Not specified in source, typically a method call in Python) ### Endpoint (Not applicable for Python methods) ### Parameters (Parameters not specified in source) ### Request Example (Not applicable for Python methods) ### Response (Response details not specified in source) ``` -------------------------------- ### Join Room by ID Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.appservice/intent.md Allows a user to start participating in a room by joining it using its ID. ```APIDOC ## join_room_by_id ### Description Start participating in a room, i.e. join it by its ID. See also: [API reference](https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidjoin) ### Parameters #### Path Parameters - **room_id** (RoomID) - Required - The ID of the room to join. #### Query Parameters - **third_party_signed** (JSON) - Optional - A signature of an `m.third_party_invite` token to prove that this user owns a third party identity which has been invited to the room. - **extra_content** (dict[str, JSON] | None) - Optional - Additional properties for the join event content. If a non-empty dict is passed, the join event will be created using the `PUT /state/m.room.member/...` endpoint instead of `POST /join`. ### Returns The ID of the room the user joined. ### Return type RoomID ``` -------------------------------- ### create_device_msc4190 Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.client.api.md Creates a new device for a user on the homeserver according to MSC4190. ```APIDOC ## create_device_msc4190 ### Description Create a Device for a user of the homeserver using appservice interface defined in MSC4190 ### Parameters #### Path Parameters - **device_id** (str) - Required - The ID of the device to create. - **initial_display_name** (str) - Required - The initial display name for the device. ### Returns None ``` -------------------------------- ### Parse matrix URI to get EventID Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.types.md Parse a matrix URI that links to an event and extract the EventID. ```python >>> MatrixURI.parse("matrix:r/room:example.com/e/abc123").event_id '$abc123' ``` -------------------------------- ### Parse matrix.to URL to get EventID Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.types.md Parse a matrix.to URL containing an event and extract the EventID. ```python >>> MatrixURI.parse("https://matrix.to/#/#room:example.com/$abc123").event_id '$abc123' ``` -------------------------------- ### Async Database with Migrations using mautrix.util.async_db Source: https://context7.com/mautrix/python/llms.txt Utilize the Database class for a unified async interface over SQLite and PostgreSQL, with schema migrations managed by UpgradeTable. Schema is auto-detected from the URL. ```python import asyncio from mautrix.util.async_db import Database, UpgradeTable ``` -------------------------------- ### WhoamiResponse Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.types.md Represents the response structure for the `GET /account/whoami` endpoint, providing information about the currently authenticated user. ```APIDOC ## Class: WhoamiResponse ### Description The response for a whoami request, as specified in the [GET /account/whoami endpoint](https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3accountwhoami) ### Fields - **user_id** ([UserID](#mautrix.types.UserID)) - Required - The Matrix User ID of the authenticated user. - **device_id** ([DeviceID](#mautrix.types.DeviceID) | None) - Optional - The ID of the device making the request, if applicable. - **is_guest** (bool) - Required - Indicates whether the authenticated user is a guest. ``` -------------------------------- ### Program Class Initialization Source: https://github.com/mautrix/python/blob/master/docs/api/mautrix.util/program.md Initializes the Program class with optional parameters for module, name, description, command, version, and config_class. ```APIDOC ## Program Class ### Description A generic main class for programs that handles argument parsing, config loading, logger setup and general startup/shutdown lifecycle. ### `__init__` Initializes the Program instance. #### Parameters * **module** (str | None) - The module name. * **name** (str | None) - The program name. * **description** (str | None) - A description for the program. * **command** (str | None) - The command name. * **version** (str | None) - The program version. * **config_class** (type[BaseFileConfig] | None) - The configuration class to use. ```