Implement room creation functions
This commit is contained in:
@@ -32,6 +32,10 @@ from .pyotherside_events import AlertRequested
|
||||
CryptDict = Dict[str, Any]
|
||||
|
||||
|
||||
@dataclass
|
||||
class RequestFailed(Exception):
|
||||
m_code: Optional[str] = None
|
||||
|
||||
@dataclass
|
||||
class UploadError(Exception):
|
||||
http_code: Optional[int] = None
|
||||
@@ -423,6 +427,30 @@ class MatrixClient(nio.AsyncClient):
|
||||
more = await self.load_past_events(room_id)
|
||||
|
||||
|
||||
async def room_create(
|
||||
self,
|
||||
name: Optional[str] = None,
|
||||
topic: Optional[str] = None,
|
||||
public: bool = False,
|
||||
encrypt: bool = False, # TODO
|
||||
federate: bool = True,
|
||||
) -> str:
|
||||
|
||||
response = await super().room_create(
|
||||
name = name,
|
||||
topic = topic,
|
||||
federate = federate,
|
||||
visibility =
|
||||
nio.RoomVisibility.public if public else
|
||||
nio.RoomVisibility.private,
|
||||
)
|
||||
|
||||
if isinstance(response, nio.RoomCreateError):
|
||||
raise RequestFailed(response.status_code)
|
||||
|
||||
return response.room_id
|
||||
|
||||
|
||||
async def room_forget(self, room_id: str) -> None:
|
||||
await super().room_leave(room_id)
|
||||
await super().room_forget(room_id)
|
||||
|
Reference in New Issue
Block a user