feat: add read receipt and presence

This commit is contained in:
əlemi 2024-01-31 02:24:07 +01:00
parent 6e7df85a5f
commit 81c005bef5
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -169,6 +169,19 @@ class AppService:
res.raise_for_status()
self.logger.debug("updated nick of %s to %s", mxid, nick)
async def set_presence(self, mxid: str, online: bool = True, status: str = "appservice presence") -> None:
async with self._client.request(
method="PUT",
url=f"{self.client_api}/presence/{mxid}/status",
headers=self.api_headers,
params={"user_id": mxid},
json={
"presence": "online" if online else "offline",
"status_msg": status,
}) as res:
res.raise_for_status()
self.logger.debug("set %s presence as %s", mxid, online)
async def invite_to_room(self, room: str, mxid: str) -> None:
async with self._client.request(
method="POST",
@ -203,8 +216,14 @@ class AppService:
self.logger.debug("sent message %s to %s as %s : %s", text, room, mxid, doc)
return doc["event_id"]
async def redact_message(self):
raise NotImplementedError
async def ack_event(self, room: str, event: str) -> None:
async with self._client.request(
method="POST",
url=f"{self.client_api}/rooms/{room}/receipt/m.read/{event}",
headers=self.api_headers,
) as res:
res.raise_for_status()
async def start(self, host: str = "localhost", port: int = 25511):
runner = web.AppRunner(self._app)