Skip to content

Commit 11c93bd

Browse files
committed
fix: caption is too long
1 parent d17176e commit 11c93bd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
Version string = "0.7.12"
10+
Version string = "0.7.13"
1111
)
1212

1313
var VersionCmd = &cobra.Command{

telegram/utils.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,15 @@ func GetArtworkHTMLCaption(artwork *types.Artwork) string {
124124
caption += "\n" + "<b>Author:</b> " + common.EscapeHTML(artwork.Artist.Name)
125125
if artwork.Description != "" {
126126
desc := artwork.Description
127-
if len(artwork.Description) > 3583 {
128-
desc = artwork.Description[:3580] + "..."
127+
if len(artwork.Description) > 500 {
128+
var n, i int
129+
for i = range desc {
130+
if n >= 500 {
131+
break
132+
}
133+
n++
134+
}
135+
desc = desc[:i] + "..."
129136
}
130137
caption += fmt.Sprintf("\n\n<blockquote expandable=true>%s</blockquote>", common.EscapeHTML(desc))
131138
}

0 commit comments

Comments
 (0)