From 62b66040e75959e7b9ea92fc00c76435e760f871 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 1 Jul 2018 18:41:05 +0300 Subject: [PATCH] Add some more debug messages to message receiving/handling --- mautrix_telegram/matrix.py | 5 +++-- mautrix_telegram/portal.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mautrix_telegram/matrix.py b/mautrix_telegram/matrix.py index 662cf48a..97c3dc8c 100644 --- a/mautrix_telegram/matrix.py +++ b/mautrix_telegram/matrix.py @@ -191,12 +191,13 @@ class MatrixHandler: return is_command, text async def handle_message(self, room, sender, message, event_id): - self.log.debug(f"{sender} sent {message} to ${room}") - is_command, text = self.is_command(message) sender = await User.get_by_mxid(sender).ensure_started() if not sender.relaybot_whitelisted: + self.log.debug(f"Ignoring message \"{message}\" from {sender} to {room}:" + " User is not whitelisted.") return + self.log.debug("Received Matrix event \"{message}\" from {sender} in {room}") portal = Portal.get_by_mxid(room) if not is_command and portal and (await sender.is_logged_in() or portal.has_bot): diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 053ea853..1f99581b 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -845,7 +845,7 @@ class Portal: await self._handle_matrix_file(type, sender_id, event_id, space, client, message, reply_to) else: - self.log.debug("Unhandled Matrix event: %s", message) + self.log.debug(f"Unhandled Matrix event: {message}") async def handle_matrix_pin(self, sender, pinned_message): if self.peer_type != "channel": @@ -1279,6 +1279,8 @@ class Portal: duplicate_found = self.is_duplicate(evt, (temporary_identifier, tg_space)) if duplicate_found: mxid, other_tg_space = duplicate_found + self.log.debug(f"Ignoring message {evt.id}@{tg_space} (src {source.tgid}) " + f"as it was already handled (in space {other_tg_space})") if tg_space != other_tg_space: self.db.add( DBMessage(tgid=evt.id, mx_room=self.mxid, mxid=mxid, tg_space=tg_space))