Skip to content
Snippets Groups Projects
Commit 5836f326 authored by Ophestra's avatar Ophestra
Browse files

escape all markdown thing

parent dd9dead6
Branches
No related tags found
No related merge requests found
...@@ -142,14 +142,17 @@ func discordHandleCreate(session *discordgo.Session, create *discordgo.MessageCr ...@@ -142,14 +142,17 @@ func discordHandleCreate(session *discordgo.Session, create *discordgo.MessageCr
} }
} }
msg.Text = discordMakeHeader(create.Author) + msg.Text
for i, attachment := range create.Message.Attachments { for i, attachment := range create.Message.Attachments {
msg.Text += fmt.Sprintf("\n[Attachment %v](%s)", i, attachment.URL) msg.Text += fmt.Sprintf("\n[Attachment %v](%s)", i, attachment.URL)
} }
msg.ParseMode = "MarkdownV2" msg.ParseMode = "MarkdownV2"
msg.Text = strings.ReplaceAll(msg.Text, ">", "\\>") msg.Text = strings.ReplaceAll(msg.Text, ">", "\\>")
msg.Text = strings.ReplaceAll(msg.Text, "_", "\\_")
msg.Text = strings.ReplaceAll(msg.Text, "*", "\\*")
msg.Text = strings.ReplaceAll(msg.Text, "[", "\\[")
msg.Text = strings.ReplaceAll(msg.Text, "`", "\\`")
msg.Text = discordMakeHeader(create.Author) + msg.Text
if m, err := botAPI.Send(msg); err != nil { if m, err := botAPI.Send(msg); err != nil {
log.Printf("error relaying message %s, %s", create.Message.ID, err) log.Printf("error relaying message %s, %s", create.Message.ID, err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment