1
0
Fork 0

Slice caption only when > 500 characters
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Daniele Tricoli 2022-03-08 01:42:37 +01:00
parent ac0d898af9
commit a9719668ee
1 changed files with 5 additions and 1 deletions

View File

@ -114,10 +114,14 @@ the specified Mastodon account.`,
log.Printf("Posted attachment %s", attachment.TextURL)
mediaIds := [...]mastodon.ID{attachment.ID}
caption := update.Message.Caption
if len(caption) > max_characters {
caption = caption[:max_characters]
}
status, err := c.PostStatus(context.Background(), &mastodon.Toot{
// Write the caption in the toot because it almost probably
// doesn't describe the image.
Status: update.Message.Caption[:max_characters],
Status: caption,
MediaIDs: mediaIds[:],
Visibility: parseMastodonVisibility(os.Getenv(MASTODON_TOOT_VISIBILITY)),
})