Fix chat creation client methods

This commit is contained in:
miruka 2019-12-29 14:30:15 -04:00
parent 10dabca1d9
commit 2ce5e20efa

View File

@ -626,13 +626,14 @@ class MatrixClient(nio.AsyncClient):
# Raise MatrixNotFound if profile doesn't exist # Raise MatrixNotFound if profile doesn't exist
await self.get_profile(invite) await self.get_profile(invite)
return await super().room_create( response = await super().room_create(
invite = [invite], invite = [invite],
is_direct = True, is_direct = True,
visibility = nio.RoomVisibility.private, visibility = nio.RoomVisibility.private,
initial_state = initial_state =
[nio.EnableEncryptionBuilder().as_dict()] if encrypt else [], [nio.EnableEncryptionBuilder().as_dict()] if encrypt else [],
).room_id )
return response.room_id
async def new_group_chat( async def new_group_chat(
@ -645,7 +646,7 @@ class MatrixClient(nio.AsyncClient):
) -> str: ) -> str:
"""Create a new matrix room with the purpose of being a group chat.""" """Create a new matrix room with the purpose of being a group chat."""
return await super().room_create( response = await super().room_create(
name = name or None, name = name or None,
topic = topic or None, topic = topic or None,
federate = federate, federate = federate,
@ -654,7 +655,8 @@ class MatrixClient(nio.AsyncClient):
nio.RoomVisibility.private, nio.RoomVisibility.private,
initial_state = initial_state =
[nio.EnableEncryptionBuilder().as_dict()] if encrypt else [], [nio.EnableEncryptionBuilder().as_dict()] if encrypt else [],
).room_id )
return response.room_id
async def room_join(self, alias_or_id_or_url: str) -> str: async def room_join(self, alias_or_id_or_url: str) -> str:
"""Join an existing matrix room.""" """Join an existing matrix room."""
@ -672,7 +674,8 @@ class MatrixClient(nio.AsyncClient):
if not self.room_id_or_alias_regex.match(string): if not self.room_id_or_alias_regex.match(string):
raise ValueError("Not an alias or room id") raise ValueError("Not an alias or room id")
return await super().join(string).room_id response = await super().join(string)
return response.room_id
async def room_forget(self, room_id: str) -> None: async def room_forget(self, room_id: str) -> None: