Await set_presence. Fixes #209

This commit is contained in:
Tulir Asokan
2018-09-01 14:03:13 +03:00
parent 731c802fcd
commit 6a1c160608
2 changed files with 4 additions and 5 deletions
+1 -1
View File
@@ -339,7 +339,7 @@ class MatrixHandler:
user = await u.User.get_by_mxid(user_id).ensure_started()
if not await user.is_logged_in():
return
user.set_presence(presence == "online")
await user.set_presence(presence == "online")
async def handle_typing(self, room_id: MatrixRoomID, now_typing: List[MatrixUserID]) -> None:
portal = po.Portal.get_by_mxid(room_id)
+3 -4
View File
@@ -199,10 +199,9 @@ class User(AbstractUser):
def ensure_started(self, even_if_no_session: bool = False) -> Coroutine[None, None, 'User']:
return cast(Coroutine[None, None, 'User'], super().ensure_started(even_if_no_session))
def set_presence(self, online: bool = True) -> bool:
if self.is_bot:
return False
return self.client(UpdateStatusRequest(offline=not online))
async def set_presence(self, online: bool = True) -> None:
if not self.is_bot:
await self.client(UpdateStatusRequest(offline=not online))
async def update_info(self, info: TLUser = None) -> None:
info = info or await self.client.get_me()