diff --git a/internal/channels/telegram/format.go b/internal/channels/telegram/format.go index 556894ba..5db344b1 100644 --- a/internal/channels/telegram/format.go +++ b/internal/channels/telegram/format.go @@ -105,11 +105,11 @@ func markdownToTelegramHTML(text string) string { // Strikethrough text = regexp.MustCompile(`~~(.+?)~~`).ReplaceAllString(text, "$1") - // Restore @mentions as clickable Telegram links + // Restore @mentions as plain text (protected from italic conversion above). + // Do NOT wrap in — LLM @mentions are not + // necessarily Telegram usernames and auto-linking shows unwanted profile cards. for i, mention := range mentionPlaceholders { - username := strings.TrimPrefix(mention, "@") - linked := fmt.Sprintf(`%s`, username, mention) - text = strings.ReplaceAll(text, fmt.Sprintf("\x00MN%d\x00", i), linked) + text = strings.ReplaceAll(text, fmt.Sprintf("\x00MN%d\x00", i), mention) } // List items diff --git a/internal/channels/telegram/format_test.go b/internal/channels/telegram/format_test.go index 72014a72..ed82395c 100644 --- a/internal/channels/telegram/format_test.go +++ b/internal/channels/telegram/format_test.go @@ -62,6 +62,58 @@ func TestRenderTableAsCode_Vietnamese(t *testing.T) { } } +func TestMarkdownToTelegramHTML_Mentions(t *testing.T) { + tests := []struct { + name string + input string + want string // substring that MUST appear + deny string // substring that must NOT appear + }{ + { + name: "mention stays plain text", + input: "Hello @viettran how are you?", + want: "@viettran", + deny: `href="https://t.me/`, + }, + { + name: "mention not wrapped in link tag", + input: "cc @john please review", + want: "@john", + deny: "