From c90f86849e27fa8eb1ac58f637f4a4d8ef929edb Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Mon, 9 May 2022 03:26:40 -0400 Subject: [PATCH] Move core of "leave" command into Portal method --- matrix_appservice_kakaotalk/commands/kakaotalk.py | 3 +-- matrix_appservice_kakaotalk/portal.py | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/matrix_appservice_kakaotalk/commands/kakaotalk.py b/matrix_appservice_kakaotalk/commands/kakaotalk.py index 31b498e..c2d7b44 100644 --- a/matrix_appservice_kakaotalk/commands/kakaotalk.py +++ b/matrix_appservice_kakaotalk/commands/kakaotalk.py @@ -311,5 +311,4 @@ async def leave(evt: CommandEvent) -> None: await evt.reply("This command may only be used in a KakaoTalk channel portal room") return await evt.mark_read() - await evt.sender.client.leave_channel(evt.portal.channel_props) - await evt.sender.on_channel_left(evt.portal.ktid, evt.portal.kt_type) + await evt.portal.leave_kakaotalk_channel() diff --git a/matrix_appservice_kakaotalk/portal.py b/matrix_appservice_kakaotalk/portal.py index 0b6d6aa..ced6dee 100644 --- a/matrix_appservice_kakaotalk/portal.py +++ b/matrix_appservice_kakaotalk/portal.py @@ -1386,6 +1386,10 @@ class Portal(DBPortal, BasePortal): else: self.log.debug(f"{user.mxid} left portal to {self.ktid}") + async def leave_kakaotalk_channel(self, user: u.User) -> None: + await user.client.leave_channel(self.channel_props) + await user.on_channel_left(self.ktid, self.kt_type) + # endregion # region KakaoTalk event handling