From d35799e2ce515aa6c67337d62cef1f2676fc11e2 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 4 Oct 2020 15:09:07 +0300 Subject: [PATCH] Add some checks --- mautrix_telegram/abstract_user.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mautrix_telegram/abstract_user.py b/mautrix_telegram/abstract_user.py index 843eb0f7..053bc89f 100644 --- a/mautrix_telegram/abstract_user.py +++ b/mautrix_telegram/abstract_user.py @@ -31,7 +31,7 @@ from telethon.tl.types import ( UpdateEditChannelMessage, UpdateEditMessage, UpdateNewChannelMessage, UpdateReadHistoryOutbox, UpdateShortChatMessage, UpdateShortMessage, UpdateUserName, UpdateUserPhoto, UpdateUserStatus, UpdateUserTyping, User, UserStatusOffline, UserStatusOnline, UpdateReadHistoryInbox, - UpdateReadChannelInbox) + UpdateReadChannelInbox, MessageEmpty) from mautrix.types import UserID, PresenceState from mautrix.errors import MatrixError @@ -388,12 +388,14 @@ class AbstractUser(ABC): elif isinstance(update, (UpdateNewMessage, UpdateNewChannelMessage, UpdateEditMessage, UpdateEditChannelMessage)): update = update.message + if isinstance(update, MessageEmpty): + return update, None, None if isinstance(update.to_id, PeerUser) and not update.out: portal = po.Portal.get_by_tgid(update.from_id, peer_type="user", tg_receiver=self.tgid) else: portal = po.Portal.get_by_entity(update.to_id, receiver_id=self.tgid) - sender = (pu.Puppet.get(update.from_id.user_id) + sender = (pu.Puppet.get(TelegramID(update.from_id.user_id)) if isinstance(update.from_id, PeerUser) else None) else: self.log.warning("Unexpected message type in User#get_message_details: "