Skip to content

Commit

Permalink
Fix forwarding from default topic
Browse files Browse the repository at this point in the history
Telegram doesn't send the default topic id

Fixes #98
  • Loading branch information
khoben committed Feb 27, 2024
1 parent ada6f77 commit bc3cb80
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions telemirror/mirroring.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ async def new_message(

for outgoing_chat, configs in outgoing_chats.items():
for config in configs:
if config.from_topic_id is not None:
# Check for incoming topic id, general topic has id = 1
if config.from_topic_id is not None and config.from_topic_id != 1:
if message.reply_to is None:
continue
# Message in the topic
if message.reply_to.reply_to_top_id is not None:
if message.reply_to.reply_to_top_id != config.from_topic_id:
continue
# Reply in the topic
else:
if message.reply_to.reply_to_msg_id != config.from_topic_id:
continue
Expand Down Expand Up @@ -192,15 +195,18 @@ async def new_album(

for outgoing_chat, configs in outgoing_chats.items():
for config in configs:
if config.from_topic_id is not None:
# Check for incoming topic id, general topic has id = 1
if config.from_topic_id is not None and config.from_topic_id != 1:
if incoming_first_message.reply_to is None:
continue
# Message in the topic
if incoming_first_message.reply_to.reply_to_top_id is not None:
if (
incoming_first_message.reply_to.reply_to_top_id
!= config.from_topic_id
):
continue
# Reply in the topic
else:
if (
incoming_first_message.reply_to.reply_to_msg_id
Expand Down

0 comments on commit bc3cb80

Please sign in to comment.