From 09cea5b43c91611530d9a6f126e30f4a59a439a6 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Sat, 3 Jul 2021 18:24:09 -0400 Subject: [PATCH] Make puppets leave instead of kicking them --- matrix_puppeteer_line/portal.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/matrix_puppeteer_line/portal.py b/matrix_puppeteer_line/portal.py index 93e013b..e43fc59 100644 --- a/matrix_puppeteer_line/portal.py +++ b/matrix_puppeteer_line/portal.py @@ -585,7 +585,7 @@ class Portal(DBPortal, BasePortal): print(current_members) - # Kick puppets who shouldn't be here + # Puppets who shouldn't be here should leave for user_id in await self.main_intent.get_room_members(self.mxid): if user_id == self.az.bot_mxid: if forbid_own_puppets and not self.needs_bridgebot: @@ -594,13 +594,11 @@ class Portal(DBPortal, BasePortal): mid = p.Puppet.get_id_from_mxid(user_id) is_own_puppet = p.Puppet.is_mid_for_own_puppet(mid) - if mid and mid not in current_members and not is_own_puppet: + if mid and mid not in current_members and not is_own_puppet \ + or forbid_own_puppets and is_own_puppet: print(mid) - await self.main_intent.kick_user(self.mxid, user_id, - reason="User had left this chat") - elif forbid_own_puppets and is_own_puppet: - await self.main_intent.kick_user(self.mxid, user_id, - reason="Kicking own puppet") + puppet = await p.Puppet.get_by_mxid(user_id) + await puppet.intent.leave_room(self.mxid) async def backfill(self, source: 'u.User', info: ChatInfo) -> None: try: