thread-master/backend/internal/library/outreach/previous_drafts.go

33 lines
789 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package outreach
import (
"fmt"
"strings"
outreachusecase "haixun-backend/internal/model/outreach_draft/domain/usecase"
)
func FormatPreviousDraftsHint(latest *outreachusecase.DraftSummary) string {
if latest == nil || len(latest.Drafts) == 0 {
return ""
}
lines := []string{"上一版草稿(請避開相同寫法):"}
for i, item := range latest.Drafts {
angle := strings.TrimSpace(item.Angle)
if angle == "" {
angle = fmt.Sprintf("版本%d", i+1)
}
lines = append(lines, fmt.Sprintf("- %s%s", angle, truncateRunes(item.Text, 140)))
}
return strings.Join(lines, "\n")
}
func truncateRunes(text string, max int) string {
text = strings.TrimSpace(text)
runes := []rune(text)
if len(runes) <= max {
return text
}
return string(runes[:max]) + "…"
}