Make puppets leave instead of kicking them

This commit is contained in:
Andrew Ferrazzutti 2021-07-03 18:24:09 -04:00
parent c4be4d79ed
commit 09cea5b43c
1 changed files with 5 additions and 7 deletions

View File

@ -585,7 +585,7 @@ class Portal(DBPortal, BasePortal):
print(current_members) 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): for user_id in await self.main_intent.get_room_members(self.mxid):
if user_id == self.az.bot_mxid: if user_id == self.az.bot_mxid:
if forbid_own_puppets and not self.needs_bridgebot: 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) mid = p.Puppet.get_id_from_mxid(user_id)
is_own_puppet = p.Puppet.is_mid_for_own_puppet(mid) 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) print(mid)
await self.main_intent.kick_user(self.mxid, user_id, puppet = await p.Puppet.get_by_mxid(user_id)
reason="User had left this chat") await puppet.intent.leave_room(self.mxid)
elif forbid_own_puppets and is_own_puppet:
await self.main_intent.kick_user(self.mxid, user_id,
reason="Kicking own puppet")
async def backfill(self, source: 'u.User', info: ChatInfo) -> None: async def backfill(self, source: 'u.User', info: ChatInfo) -> None:
try: try: