mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-11-09 15:40:03 +00:00
Add auto_publish functionality for liveposting module
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
5bd54dd15c
commit
d8abfbac35
2 changed files with 16 additions and 3 deletions
|
@ -226,7 +226,9 @@ func (m modLivePosting) sendLivePost(username, displayName, title, game, preview
|
||||||
)
|
)
|
||||||
|
|
||||||
// @attr discord_channel_id required string "" ID of the Discord channel to post the message to
|
// @attr discord_channel_id required string "" ID of the Discord channel to post the message to
|
||||||
msgs, err := m.discord.ChannelMessages(m.attrs.MustString("discord_channel_id", nil), livePostingNumberOfMessagesToLoad, "", "", "")
|
channelID := m.attrs.MustString("discord_channel_id", nil)
|
||||||
|
|
||||||
|
msgs, err := m.discord.ChannelMessages(channelID, livePostingNumberOfMessagesToLoad, "", "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "fetching previous messages")
|
return errors.Wrap(err, "fetching previous messages")
|
||||||
}
|
}
|
||||||
|
@ -282,10 +284,20 @@ func (m modLivePosting) sendLivePost(username, displayName, title, game, preview
|
||||||
URL: strings.Join([]string{"https://www.twitch.tv", username}, "/"),
|
URL: strings.Join([]string{"https://www.twitch.tv", username}, "/"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = m.discord.ChannelMessageSendComplex(m.attrs.MustString("discord_channel_id", nil), &discordgo.MessageSend{
|
msg, err := m.discord.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{
|
||||||
Content: postText,
|
Content: postText,
|
||||||
Embed: msgEmbed,
|
Embed: msgEmbed,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "sending message")
|
||||||
|
}
|
||||||
|
|
||||||
return errors.Wrap(err, "sending message")
|
// @attr auto_publish optional bool "false" Automatically publish (crosspost) the message to followers of the channel
|
||||||
|
if m.attrs.MustBool("auto_publish", ptrBoolFalse) {
|
||||||
|
if _, err = m.discord.ChannelMessageCrosspost(channelID, msg.ID); err != nil {
|
||||||
|
return errors.Wrap(err, "publishing message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ Announces stream live status based on Discord streaming status
|
||||||
| `post_text` | ✅ | string | | Message to post to channel use `${displayname}` and `${username}` as placeholders |
|
| `post_text` | ✅ | string | | Message to post to channel use `${displayname}` and `${username}` as placeholders |
|
||||||
| `twitch_client_id` | ✅ | string | | Twitch client ID the token was issued for |
|
| `twitch_client_id` | ✅ | string | | Twitch client ID the token was issued for |
|
||||||
| `twitch_client_secret` | ✅ | string | | Secret for the Twitch app identified with twitch_client_id |
|
| `twitch_client_secret` | ✅ | string | | Secret for the Twitch app identified with twitch_client_id |
|
||||||
|
| `auto_publish` | | bool | `false` | Automatically publish (crosspost) the message to followers of the channel |
|
||||||
| `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 |
|
| `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 |
|
| `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) |
|
||||||
|
|
Loading…
Reference in a new issue