feat: add read receipt and presence
This commit is contained in:
parent
6e7df85a5f
commit
81c005bef5
1 changed files with 21 additions and 2 deletions
|
@ -169,6 +169,19 @@ class AppService:
|
||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
self.logger.debug("updated nick of %s to %s", mxid, nick)
|
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 def invite_to_room(self, room: str, mxid: str) -> None:
|
||||||
async with self._client.request(
|
async with self._client.request(
|
||||||
method="POST",
|
method="POST",
|
||||||
|
@ -203,8 +216,14 @@ class AppService:
|
||||||
self.logger.debug("sent message %s to %s as %s : %s", text, room, mxid, doc)
|
self.logger.debug("sent message %s to %s as %s : %s", text, room, mxid, doc)
|
||||||
return doc["event_id"]
|
return doc["event_id"]
|
||||||
|
|
||||||
async def redact_message(self):
|
async def ack_event(self, room: str, event: str) -> None:
|
||||||
raise NotImplementedError
|
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):
|
async def start(self, host: str = "localhost", port: int = 25511):
|
||||||
runner = web.AppRunner(self._app)
|
runner = web.AppRunner(self._app)
|
||||||
|
|
Loading…
Reference in a new issue