diff --git a/mautrix_telegram/formatter.py b/mautrix_telegram/formatter.py index ec186337..2aaba0fa 100644 --- a/mautrix_telegram/formatter.py +++ b/mautrix_telegram/formatter.py @@ -218,7 +218,8 @@ def telegram_event_to_matrix(evt, source): + f"
{html}
") if evt.reply_to_msg_id: - msg = DBMessage.query.get((evt.reply_to_msg_id, source.tgid)) + space = evt.to_id.channel_id if isinstance(evt, Message) and isinstance(evt.to_id, PeerChannel) else source.tgid + msg = DBMessage.query.get((evt.reply_to_msg_id, space)) if msg: quote = f"Quote
" if html: diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 0a522068..a3c9fce5 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -90,10 +90,10 @@ class Portal: # to deduplicate based on a hash of the message content. # The timestamp is only accurate to the second, so we can't rely on solely that either. - hash_content = [str(event.date.timestamp()), event.from_id, event.message] + hash_content = [event.date.timestamp(), event.message] if event.fwd_from: hash_content += [event.fwd_from.from_id, event.fwd_from.channel_id] - elif event.media: + elif isinstance(event, Message) and event.media: try: hash_content += { MessageMediaContact: lambda media: [media.user_id],