1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-03 00:42:48 +02:00

Add a script to launch the third phase

This commit is contained in:
Yohann D'ANELLO
2020-11-01 20:28:43 +01:00
parent 4f1f4b0783
commit bcca41bfb6
2 changed files with 65 additions and 0 deletions

View File

@ -238,6 +238,29 @@ class Matrix:
room_id = await cls.resolve_room_alias(room_id)
return await client.room_invite(room_id, user_id)
@classmethod
@async_to_sync
async def send_message(cls, room_id: str, body: str, formatted_body: str = None,
msgtype: str = "m.text", html: bool = True):
"""
Send a message to a room.
"""
client = await cls._get_client()
if room_id.startswith("#"):
room_id = await cls.resolve_room_alias(room_id)
content = {
"msgtype": msgtype,
"body": body,
"formatted_body": formatted_body or body,
}
if html:
content["format"] = "org.matrix.custom.html"
return await client.room_send(
room_id=room_id,
message_type="m.room.message",
content=content,
)
@classmethod
@async_to_sync
async def kick(cls, room_id: str, user_id: str, reason: str = None) -> Union[RoomKickResponse, RoomInviteError]: