From e0f21ed8249bd73a7096abf4de713b3fde85690c Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Mon, 5 Jul 2021 18:51:29 -0400 Subject: [PATCH] Don't error on member leave if puppet left already --- matrix_puppeteer_line/portal.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matrix_puppeteer_line/portal.py b/matrix_puppeteer_line/portal.py index 4bd4879..085ed95 100644 --- a/matrix_puppeteer_line/portal.py +++ b/matrix_puppeteer_line/portal.py @@ -30,6 +30,7 @@ from mautrix.types import (EventID, MessageEventContent, RoomID, EventType, Mess ContentURI, EncryptedFile, ImageInfo, RelatesTo, RelationType) from mautrix.errors import IntentError +from mautrix.errors.request import MatrixRequestError from mautrix.util.simple_lock import SimpleLock from .db import Portal as DBPortal, Message as DBMessage, Receipt as DBReceipt, ReceiptReaction as DBReceiptReaction, Media as DBMedia @@ -370,7 +371,10 @@ class Portal(DBPortal, BasePortal): if evt.member_info.joined: await intent.ensure_joined(self.mxid) elif evt.member_info.left: - await intent.leave_room(self.mxid) + try: + await intent.leave_room(self.mxid) + except MatrixRequestError as e: + self.log.warn(f"Puppet for user {evt.sender.id} already left portal {self.mxid}") event_id = None else: content = TextMessageEventContent(