feat(discord): support referenced/quoted messages in replies

When a user replies to a message in Discord, the bot now reads
m.ReferencedMessage and prepends its content to the incoming
message as '[quoted message from Username]: content'.

This gives the LLM full context of what message the user is
replying to, enabling meaningful follow-up conversations.
This commit is contained in:
王路路
2026-03-04 09:13:20 +08:00
parent bea238c337
commit 465819e1c6
+9
View File
@@ -338,6 +338,15 @@ func (c *DiscordChannel) handleMessage(s *discordgo.Session, m *discordgo.Messag
content = c.stripBotMention(content)
}
// Prepend referenced (quoted) message content if this is a reply
if m.MessageReference != nil && m.ReferencedMessage != nil {
refContent := m.ReferencedMessage.Content
if refContent != "" {
content = fmt.Sprintf("[quoted message from %s]: %s\n\n%s",
m.ReferencedMessage.Author.Username, refContent, content)
}
}
senderID := m.Author.ID
mediaPaths := make([]string, 0, len(m.Attachments))