forked from mirror/mautrix-discord
Allow inline links in normal messages
This commit is contained in:
parent
fb6d89a88f
commit
345391f8b1
2 changed files with 9 additions and 1 deletions
|
@ -216,6 +216,14 @@ var matrixHTMLParser = &format.HTMLParser{
|
|||
}
|
||||
return fmt.Sprintf("||%s||", text)
|
||||
},
|
||||
LinkConverter: func(text, href string, ctx format.Context) string {
|
||||
if text == href {
|
||||
return text
|
||||
} else if !discordLinkRegexFull.MatchString(href) {
|
||||
return fmt.Sprintf("%s (%s)", escapeDiscordMarkdown(text), escapeDiscordMarkdown(href))
|
||||
}
|
||||
return fmt.Sprintf("[%s](%s)", escapeDiscordMarkdown(text), href)
|
||||
},
|
||||
}
|
||||
|
||||
func (portal *Portal) parseMatrixHTML(content *event.MessageEventContent) (string, *discordgo.MessageAllowedMentions) {
|
||||
|
|
|
@ -673,7 +673,7 @@ func (portal *Portal) convertDiscordTextMessage(ctx context.Context, intent *app
|
|||
htmlParts = append(htmlParts, fmt.Sprintf(msgInteractionTemplateHTML, puppet.MXID, puppet.Name, msg.Interaction.Name))
|
||||
}
|
||||
if msg.Content != "" && !isPlainGifMessage(msg) {
|
||||
htmlParts = append(htmlParts, portal.renderDiscordMarkdownOnlyHTML(msg.Content, false))
|
||||
htmlParts = append(htmlParts, portal.renderDiscordMarkdownOnlyHTML(msg.Content, true))
|
||||
}
|
||||
previews := make([]*BeeperLinkPreview, 0)
|
||||
for i, embed := range msg.Embeds {
|
||||
|
|
Loading…
Reference in a new issue