mautrix.client package¶
Subpackages¶
- mautrix.client.api package
- Subpackages
- mautrix.client.api.modules package
- mautrix.client.api.types package
- Subpackages
- mautrix.client.api.types.event package
- Submodules
- mautrix.client.api.types.event.account_data module
- mautrix.client.api.types.event.base module
- mautrix.client.api.types.event.generic module
- mautrix.client.api.types.event.message module
- mautrix.client.api.types.event.redaction module
- mautrix.client.api.types.event.state module
- Module contents
- mautrix.client.api.types.util package
- mautrix.client.api.types.event package
- Submodules
- mautrix.client.api.types.filter module
- mautrix.client.api.types.media module
- mautrix.client.api.types.misc module
- mautrix.client.api.types.primitive module
- mautrix.client.api.types.users module
- Module contents
- Subpackages
- Submodules
- mautrix.client.api.base module
- mautrix.client.api.client module
- mautrix.client.api.events module
- mautrix.client.api.filtering module
- mautrix.client.api.rooms module
- mautrix.client.api.user_data module
- Module contents
- Subpackages
Submodules¶
mautrix.client.client module¶
-
class
mautrix.client.client.Client(*args, store: mautrix.client.store.ClientStore = None, **kwargs)[source]¶ Bases:
mautrix.client.api.client.ClientAPIClient is a high-level wrapper around the client API.
-
add_event_handler(event_type: mautrix.client.api.types.event.base.EventType, handler: Callable[NewType.<locals>.new_type, Awaitable[None]]) → None[source]¶ Add a new event handler.
Parameters: - event_type (
EventType) – The event type to add. If not specified, the handler will be called for all event types. - handler (
Callable[[Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]],Awaitable[None]]) – The handler function to add.
Return type: None- event_type (
-
call_handlers(event: NewType.<locals>.new_type, source: mautrix.client.client.SyncStream) → None[source]¶ Send the given event to all applicable event handlers.
Parameters: - event (
Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]) – The event to send. - source (
SyncStream) – The sync stream the event was received in.
Return type: None- event (
-
handle_sync(data: NewType.<locals>.new_type) → None[source]¶ Handle a /sync object.
Parameters: data ( JSON[Union[str,int,float,None,Dict[str,_Forwardref],List[_Forwardref]]]) – The data from a /sync request.Return type: None
-
on(var: Union[Callable[NewType.<locals>.new_type, Awaitable[None]], mautrix.client.api.types.event.base.EventType]) → Union[Callable[NewType.<locals>.new_type, Awaitable[None]], Callable[Callable[NewType.<locals>.new_type, Awaitable[None]], Callable[NewType.<locals>.new_type, Awaitable[None]]]][source]¶ Add a new event handler. This method is for decorator usage. Use
add_event_handler()if you don’t use a decorator.Parameters: var ( Union[Callable[[Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]],Awaitable[None]],EventType]) – Either the handler function or the event type to handle.Return type: Union[Callable[[Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]],Awaitable[None]],Callable[[Callable[[Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]],Awaitable[None]]],Callable[[Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]],Awaitable[None]]]]Returns: If varwas the handler function, the handler function is returned.If
varwas an event type, a function that takes the handler function as an argument is returned.Examples
>>> client = Client(...) >>> @client.on(EventType.ROOM_MESSAGE) >>> def handler(event: MessageEvent) -> None: ... pass
-
remove_event_handler(event_type: mautrix.client.api.types.event.base.EventType, handler: Callable[NewType.<locals>.new_type, Awaitable[None]]) → None[source]¶ Remove an event handler.
Parameters: - handler (
Callable[[Event[Union[MessageEvent,ReactionEvent,RedactionEvent,StateEvent,ReceiptEvent,PresenceEvent,TypingEvent,GenericEvent]]],Awaitable[None]]) – The handler function to remove. - event_type (
EventType) – The event type to remove the handler function from.
Return type: None- handler (
-
start(filter_data: Union[NewType.<locals>.new_type, mautrix.client.api.types.filter.Filter, None]) → _asyncio.Future[source]¶ Start syncing with the server. Can be stopped with
stop().Parameters: filter_data ( Union[FilterID[str],Filter,None]) – The filter data or filter ID to use for syncing.Return type: Future
-
mautrix.client.store module¶
-
class
mautrix.client.store.ClientStore[source]¶ Bases:
abc.ABCClientStore persists high-level client stuff.
-
next_batch¶ Return type: SyncToken[str]
-
-
class
mautrix.client.store.MemoryClientStore(next_batch: Optional[NewType.<locals>.new_type] = None)[source]¶ Bases:
mautrix.client.store.ClientStoreMemoryClientStore is a
ClientStoreimplementation that stores the data in memory.-
next_batch¶ Return type: Optional[SyncToken[str]]
-