Skip to content

Commit

Permalink
feat: enhance artwork caption with username and website link
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Jan 27, 2025
1 parent 26ff8a2 commit 18256f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion telegram/utils/post_artwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,13 @@ func recaptionArtwork(ctx context.Context, artwork *types.Artwork, bot *telego.B
return
}
newCaption := GetArtworkHTMLCaption(newArtwork)
bot.EditMessageCaption(&telego.EditMessageCaptionParams{
_, err = bot.EditMessageCaption(&telego.EditMessageCaptionParams{
ChatID: ChannelChatID,
MessageID: newArtwork.Pictures[0].TelegramInfo.MessageID,
Caption: newCaption,
ParseMode: telego.ModeHTML,
})
if err != nil {
common.Logger.Warnf("error when recaption artwork: %s", err)
}
}
11 changes: 10 additions & 1 deletion telegram/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ func GetArtworkHTMLCaption(artwork *types.Artwork) string {
tag = tagCharsReplacer.Replace(tag)
tags += "#" + strings.TrimSpace(common.EscapeHTML(tag)) + " "
}
caption += fmt.Sprintf("\n<blockquote expandable=true>%s</blockquote>", tags)
caption += fmt.Sprintf("\n<blockquote expandable=true>%s</blockquote>\n", tags)
if ChannelChatID.Username != "" {
caption += common.EscapeHTML(ChannelChatID.Username)
}
if artwork.ID != "" && config.Cfg.API.SiteURL != "" {
if ChannelChatID.Username != "" {
caption += " | "
}
caption += fmt.Sprintf("<a href=\"%s/artwork/%s\">在网站查看</a>", config.Cfg.API.SiteURL, artwork.ID)
}
return caption
}

Expand Down

0 comments on commit 18256f0

Please sign in to comment.