fix: QQ发送消息时剥离Markdown格式 — 防止**粗体**等标记泄露到聊天
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -358,6 +358,7 @@ func startQQReaders(router *bridge.PlatformRouter) {
|
||||
var toSend []bridge.ResponseMessage
|
||||
for _, rm := range response.Messages {
|
||||
if rm.Content != "" {
|
||||
rm.Content = qqadapter.ConvertMarkdownToQQ(rm.Content)
|
||||
toSend = append(toSend, rm)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ func (a *Adapter) ToUnified(rawMessage interface{}) (*bridge.UnifiedMessage, err
|
||||
func (a *Adapter) FromUnified(response *bridge.UnifiedResponse) ([]bridge.PlatformMessage, error) {
|
||||
var msgs []bridge.PlatformMessage
|
||||
for _, rm := range response.Messages {
|
||||
content := convertMarkdownToQQ(rm.Content)
|
||||
content := ConvertMarkdownToQQ(rm.Content)
|
||||
runes := []rune(content)
|
||||
if len(runes) > 200 {
|
||||
content = string(runes[:200])
|
||||
@@ -572,8 +572,8 @@ func extractAttachments(msg *OBv11Message) []bridge.Attachment {
|
||||
return attachments
|
||||
}
|
||||
|
||||
// convertMarkdownToQQ converts markdown to QQ plain-text format.
|
||||
func convertMarkdownToQQ(md string) string {
|
||||
// ConvertMarkdownToQQ converts markdown to QQ plain-text format.
|
||||
func ConvertMarkdownToQQ(md string) string {
|
||||
md = boldRegex.ReplaceAllString(md, "$1")
|
||||
md = italicRegex.ReplaceAllString(md, "$1")
|
||||
md = strikethroughRegex.ReplaceAllString(md, "$1")
|
||||
|
||||
Reference in New Issue
Block a user