Skip to content

Commit b92ae43

Browse files
committed
Исправлена ошибка с неправильным цитированием в группах
1 parent 4b50919 commit b92ae43

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/telegram.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,21 @@ export async function launch(token: string, handler: MessageHandler): Promise<Sh
4545
}
4646

4747
if (message.message_thread_id) {
48-
// If there are topics in the group, write a reply to it.
49-
// Otherwise, it's a comment under a post in the linked group
5048
if (message.sender_chat?.is_forum) {
49+
// If there are topics in the group, write to the correct one
5150
threadId = message.message_thread_id;
52-
} else {
51+
} else if (message.reply_to_message?.sender_chat?.type === 'channel') {
52+
// This is the comment under the post
5353
replyToMessageId = message.message_thread_id;
54+
} else {
55+
// This is the reply to some comment under the post
56+
// TODO: This is not a perfect solution, as there is no way to distinguish between a reply to a comment
57+
// under a post and a simple reply in a supergroup chat.
58+
// But if I don't do this, the bot will post a response to a comment with a reply just
59+
// to the group bound to the channel.
60+
// This solution fixes comments under posts, but leads to the creation of unwanted quotes on
61+
// messages with replies in supergroups.
62+
replyToMessageId = message.message_id;
5463
}
5564
}
5665

0 commit comments

Comments
 (0)