matridge.session
#
Module Contents#
Classes#
The session of a registered User. |
Functions#
|
Attributes#
- class matridge.session.Session(*a)[source]#
Bases:
slidge.BaseSession
[str
,Recipient
]The session of a registered User.
Represents a gateway user logged in to the legacy network and performing actions.
Will be instantiated automatically on slidge startup for each registered user, or upon registration for new (validated) users.
Must be subclassed for a functional Legacy Module.
- async login()[source]#
Logs in the gateway user to the legacy network.
Triggered when the gateway start and on user registration. It is recommended that this function returns once the user is logged in, so if you need to await forever (for instance to listen to incoming events), it’s a good idea to wrap your listener in an asyncio.Task.
- Returns:
Optionally, a text to use as the gateway status, e.g., “Connected as ‘dude@legacy.network’”
- async logout()[source]#
Logs out the gateway user from the legacy network.
Called on gateway shutdown.
- async __relates_to(room_id, content, reply_to_msg_id, thread)[source]#
- Parameters:
room_id (str) –
content (dict[str, Any]) –
reply_to_msg_id (Optional[str]) –
thread (Optional[str]) –
- async __room_send(chat, content, message_type='m.room.message')[source]#
- Parameters:
chat (matridge.group.MUC) –
content (dict) –
- async send_text(chat, text, *, reply_to_msg_id=None, reply_to_fallback_text=None, reply_to=None, thread=None)[source]#
- Parameters:
chat (matridge.group.MUC) –
text (str) –
reply_to_msg_id (Optional[str]) –
reply_to_fallback_text (Optional[str]) –
reply_to (Optional[Sender]) –
thread (Optional[str]) –
- Return type:
Optional[slidge.util.types.LegacyMessageType]
- async send_file(chat, url, *, http_response, reply_to_msg_id=None, reply_to_fallback_text=None, reply_to=None, thread=None)[source]#
- Parameters:
chat (matridge.group.MUC) –
url (str) –
http_response (aiohttp.ClientResponse) –
reply_to_msg_id (Optional[str]) –
reply_to_fallback_text (Optional[str]) –
reply_to (Optional[Sender]) –
thread (Optional[str]) –
- Return type:
Optional[slidge.util.types.LegacyMessageType]
- async active(c, thread=None)[source]#
- Parameters:
c (slidge.util.types.RecipientType) –
thread (Optional[slidge.util.types.LegacyThreadType]) –
- async inactive(c, thread=None)[source]#
- Parameters:
c (slidge.util.types.RecipientType) –
thread (Optional[slidge.util.types.LegacyThreadType]) –
- async composing(c, thread=None)[source]#
- Parameters:
c (matridge.group.MUC) –
thread (Optional[slidge.util.types.LegacyThreadType]) –
- async paused(c, thread=None)[source]#
- Parameters:
c (matridge.group.MUC) –
thread (Optional[slidge.util.types.LegacyThreadType]) –
- async displayed(c, legacy_msg_id, thread=None)[source]#
- Parameters:
c (slidge.util.types.RecipientType) –
legacy_msg_id (slidge.util.types.LegacyMessageType) –
thread (Optional[slidge.util.types.LegacyThreadType]) –
- async correct(c, text, legacy_msg_id, thread=None)[source]#
- Parameters:
c (matridge.group.MUC) –
text (str) –
legacy_msg_id (str) –
thread (Optional[str]) –
- Return type:
Optional[str]
- async search(form_values)[source]#
- Parameters:
form_values (dict[str, str]) –
- Return type:
Optional[slidge.SearchResult]
- async react(c, legacy_msg_id, emojis, thread=None)[source]#
- Parameters:
c (matridge.group.MUC) –
legacy_msg_id (str) –
emojis (list[str]) –
thread (Optional[slidge.util.types.LegacyThreadType]) –