1
0
Fork 0

Make possible to set an optional footer for toots
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Daniele Tricoli 2022-03-13 00:30:41 +01:00
parent 30a96b9e27
commit 2c2331c371
2 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,7 @@ public groups.
|--------------------------------|------------------------------|----------|
| `MASTODON_ACCESS_TOKEN` | Mastodon access token | *N/A* |
| `MASTODON_SERVER_ADDRESS` | Mastodon server address | *N/A* |
| `MASTODON_TOOT_FOOTER ` | Footer of each toot | "" |
| `MASTODON_TOOT_MAX_CHARACTERS` | Toot max lenght | 500 |
| `MASTODON_TOOT_VISIBILITY` | Default toot visibility | unlisted |
| `TELEGRAM_BOT_TOKEN` | Telegram bot token | *N/A* |
@ -31,6 +32,9 @@ public groups.
`MASTODON_TOOT_VISIBILITY` allowed values are: `direct`, `private`, `public`
and `unlisted`.
`MASTODON_TOOT_FOOTER` default is an empty string that disable the footer
feature, no character ad automatically added so you may want to add a space
before your footer (or a new line).
To get `MASTODON_ACCESS_TOKEN` see next point.
4. To get `MASTODON_ACCESS_TOKEN` use the subcommand `authenticate`:
```

View File

@ -79,7 +79,10 @@ the specified Mastodon account.`,
text := update.Message.Text
in_reply_to := ""
for _, message := range utils.SplitTextAtChunk(text, max_characters, "") {
toot_footer := os.Getenv(MASTODON_TOOT_FOOTER)
messages := utils.SplitTextAtChunk(text, max_characters, toot_footer)
for _, message := range messages {
status, err := c.PostStatus(context.Background(), &mastodon.Toot{
Status: message,
Visibility: parseMastodonVisibility(os.Getenv(MASTODON_TOOT_VISIBILITY)),