Awaitable and mark_read for account/friend management commands
This commit is contained in:
parent
c3b299d26c
commit
dcf17fd40a
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue