From a9719668ee160e8fcb6bedfcb505699c5eee7c9a Mon Sep 17 00:00:00 2001 From: Daniele Tricoli Date: Tue, 8 Mar 2022 01:42:37 +0100 Subject: [PATCH] Slice caption only when > 500 characters --- cmd/run.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/run.go b/cmd/run.go index 916b8e9..c10d7e2 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -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)), })