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:
@ -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]:
|
||||
|
Reference in New Issue
Block a user