mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-11-09 15:40:03 +00:00
[liveposting] Add option to remove older messages for the same channel
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9c2c301bbb
commit
8d0264c133
2 changed files with 20 additions and 1 deletions
|
@ -252,10 +252,28 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "parsing message timestamp")
|
return errors.Wrap(err, "parsing message timestamp")
|
||||||
}
|
}
|
||||||
if msg.Content == postText && time.Since(mt) < ignoreTime {
|
|
||||||
|
if msg.Content != postText {
|
||||||
|
// Post is for another channel / is another message
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Since(mt) < ignoreTime {
|
||||||
|
// Message is still fresh
|
||||||
logger.Debug("Not creating live-post, it's already there")
|
logger.Debug("Not creating live-post, it's already there")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @attr remove_old optional bool "false" If set to `true` older message with same content will be deleted
|
||||||
|
if !m.attrs.MustBool("remove_old", ptrBoolFalse) {
|
||||||
|
// We're not allowed to purge the old message
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purge the old message
|
||||||
|
if err = m.discord.ChannelMessageDelete(channelID, msg.ID); err != nil {
|
||||||
|
return errors.Wrap(err, "deleting old message")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discord caches the images and the URLs do not change every time
|
// Discord caches the images and the URLs do not change every time
|
||||||
|
|
|
@ -85,6 +85,7 @@ Announces stream live status based on Discord streaming status
|
||||||
| `disable_presence` | | bool | `false` | Disable posting live-postings for discord presence changes |
|
| `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) |
|
| `poll_usernames` | | []string | `[]` | Check these usernames for active streams when executing the `cron` (at most 100 users can be checked) |
|
||||||
| `preserve_proxy` | | string | | URL prefix of a Luzifer/preserve proxy to cache stream preview for longer |
|
| `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 |
|
| `stream_freshness` | | duration | `5m` | How long after stream start to post shoutout |
|
||||||
| `whitelisted_role` | | string | | Only post for members of this role ID |
|
| `whitelisted_role` | | string | | Only post for members of this role ID |
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue