From dcf17fd40adce6381828a931816e9a48891ecde0 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Fri, 6 May 2022 02:49:49 -0400 Subject: [PATCH] Awaitable and mark_read for account/friend management commands --- matrix_appservice_kakaotalk/commands/kakaotalk.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/matrix_appservice_kakaotalk/commands/kakaotalk.py b/matrix_appservice_kakaotalk/commands/kakaotalk.py index 85c1443..46d6979 100644 --- a/matrix_appservice_kakaotalk/commands/kakaotalk.py +++ b/matrix_appservice_kakaotalk/commands/kakaotalk.py @@ -167,9 +167,9 @@ async def _get_search_result_puppet(source: u.User, friend_struct: FriendStruct) help_text="List all KakaoTalk friends", ) async def list_friends(evt: CommandEvent) -> None: + await evt.mark_read() try: resp = await evt.sender.client.list_friends() - await evt.mark_read() except CommandException as e: await evt.reply(f"Error while listing friends: {e!s}") return @@ -220,8 +220,8 @@ async def _get_id_from_mxid(mxid: UserID) -> Long | None: help_text="Add a KakaoTalk user to your KakaoTalk friends list", help_args="<_KakaoTalk ID_|_Matrix user ID_>", ) -async def add_friend(evt: CommandEvent) -> None: - await _edit_friend(evt, True) +def add_friend(evt: CommandEvent) -> Awaitable[None]: + return _edit_friend(evt, True) @command_handler( needs_auth=True, @@ -230,8 +230,8 @@ async def add_friend(evt: CommandEvent) -> None: help_text="Remove a KakaoTalk user from your KakaoTalk friends list", help_args="<_KakaoTalk ID_|_Matrix user ID_>", ) -async def remove_friend(evt: CommandEvent) -> None: - await _edit_friend(evt, False) +def remove_friend(evt: CommandEvent) -> Awaitable[None]: + return _edit_friend(evt, False) async def _edit_friend(evt: CommandEvent, add: bool) -> None: if not evt.args: @@ -266,6 +266,7 @@ async def _edit_friend(evt: CommandEvent, add: bool) -> None: await _edit_friend_by_uuid(evt, arg, add) async def _edit_friend_by_ktid(evt: CommandEvent, ktid: Long, add: bool) -> None: + await evt.mark_read() try: friend_struct = await evt.sender.client.edit_friend(ktid, add) except RPCError as e: @@ -274,6 +275,7 @@ async def _edit_friend_by_ktid(evt: CommandEvent, ktid: Long, add: bool) -> None await _on_friend_edited(evt, friend_struct, add) async def _edit_friend_by_uuid(evt: CommandEvent, uuid: str, add: bool) -> None: + await evt.mark_read() try: friend_struct = await evt.sender.client.edit_friend_by_uuid(uuid, add) except RPCError as e: