[liveposting] Allow to override the post text for specific users

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-11-16 00:12:20 +01:00
parent 8d0264c133
commit eeb77f0f00
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 7 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/base64"
"fmt"
"net/url"
"strconv"
"strings"
@ -230,12 +231,15 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
"game": game,
})
// @attr post_text required string "" Message to post to channel use `${displayname}` and `${username}` as placeholders
postTemplateDefault := m.attrs.MustString("post_text", nil)
postText := strings.NewReplacer(
"${displayname}", displayName,
"${username}", username,
).Replace(
// @attr post_text required string "" Message to post to channel use `${displayname}` and `${username}` as placeholders
m.attrs.MustString("post_text", nil),
// @attr post_text_{username} optional string "" Override the default `post_text` with this one (e.g. `post_text_luziferus: "${displayName} is now live"`)
m.attrs.MustString(fmt.Sprintf("post_text_%s", strings.ToLower(username)), &postTemplateDefault),
)
// @attr discord_channel_id required string "" ID of the Discord channel to post the message to

View file

@ -84,6 +84,7 @@ Announces stream live status based on Discord streaming status
| `cron` | | string | `*/5 * * * *` | Fetch live status of `poll_usernames` (set to empty string to disable): keep this below `stream_freshness` or you might miss streams |
| `disable_presence` | | bool | `false` | Disable posting live-postings for discord presence changes |
| `poll_usernames` | | []string | `[]` | Check these usernames for active streams when executing the `cron` (at most 100 users can be checked) |
| `post_text_{username}` | | string | | Override the default `post_text` with this one (e.g. `post_text_luziferus: "${displayName} is now live"`) |
| `preserve_proxy` | | string | | URL prefix of a Luzifer/preserve proxy to cache stream preview for longer |
| `remove_old` | | bool | `false` | If set to `true` older message with same content will be deleted |
| `stream_freshness` | | duration | `5m` | How long after stream start to post shoutout |