diff --git a/src/go.mod b/src/go.mod index 324873b..f121780 100644 --- a/src/go.mod +++ b/src/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/go-git/go-git/v5 v5.12.0 - github.com/nicklaw5/helix/v2 v2.28.3 + github.com/nicklaw5/helix/v2 v2.30.0 github.com/nikoksr/notify v0.41.0 github.com/sirupsen/logrus v1.9.3 ) diff --git a/src/go.sum b/src/go.sum index 1b89ed2..bb22327 100644 --- a/src/go.sum +++ b/src/go.sum @@ -34,7 +34,6 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= -github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -54,8 +53,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/nicklaw5/helix/v2 v2.28.3 h1:hpy+VxMhEgDCoh8wAUS3mIqUYh0KcfJnd8w8uUOjZ3Y= -github.com/nicklaw5/helix/v2 v2.28.3/go.mod h1:zZcKsyyBWDli34x3QleYsVMiiNGMXPAEU5NjsiZDtvY= +github.com/nicklaw5/helix/v2 v2.30.0 h1:bmkVnczkSj2Oa7K0gmHFqnurYDoEVapwpQhxa7haC98= +github.com/nicklaw5/helix/v2 v2.30.0/go.mod h1:zZcKsyyBWDli34x3QleYsVMiiNGMXPAEU5NjsiZDtvY= github.com/nikoksr/notify v0.41.0 h1:4LGE41GpWdHX5M3Xo6DlWRwS2WLDbOq1Rk7IzY4vjmQ= github.com/nikoksr/notify v0.41.0/go.mod h1:FoE0UVPeopz1Vy5nm9vQZ+JVmYjEIjQgbFstbkw+cRE= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= diff --git a/src/vendor/github.com/nicklaw5/helix/v2/SUPPORTED_ENDPOINTS.md b/src/vendor/github.com/nicklaw5/helix/v2/SUPPORTED_ENDPOINTS.md index 2c70ce5..71b90dc 100644 --- a/src/vendor/github.com/nicklaw5/helix/v2/SUPPORTED_ENDPOINTS.md +++ b/src/vendor/github.com/nicklaw5/helix/v2/SUPPORTED_ENDPOINTS.md @@ -77,6 +77,7 @@ - [x] Add Blocked Term - [x] Remove Blocked Term - [x] Delete Chat Messages +- [x] Get Moderated Channels - [x] Get Moderators - [x] Add Channel Moderator - [x] Remove Channel Moderator @@ -123,3 +124,4 @@ - [x] Delete Videos - [x] Send Whisper - [x] Get Webhook Subscriptions +- [x] Warn Chat User diff --git a/src/vendor/github.com/nicklaw5/helix/v2/moderation.go b/src/vendor/github.com/nicklaw5/helix/v2/moderation.go index e69c1dd..d2c61f7 100644 --- a/src/vendor/github.com/nicklaw5/helix/v2/moderation.go +++ b/src/vendor/github.com/nicklaw5/helix/v2/moderation.go @@ -380,3 +380,105 @@ func (c *Client) RemoveChannelModerator(params *RemoveChannelModeratorParams) (* return moderators, nil } + +// `UserID` must match the user ID in the User-Access token +type GetModeratedChannelsParams struct { + // Required + UserID string `query:"user_id"` + + // Optional + After string `query:"after"` + First int `query:"first"` +} + +type ModeratedChannel struct { + BroadcasterID string `json:"broadcaster_id"` + BroadcasterLogin string `json:"broadcaster_login"` + BroadcasterName string `json:"broadcaster_name"` +} + +type ManyModeratedChannels struct { + ModeratedChannels []ModeratedChannel `json:"data"` + Pagination Pagination `json:"pagination"` +} + +type GetModeratedChannelsResponse struct { + ResponseCommon + Data ManyModeratedChannels +} + +// GetModeratedChannels Gets a list of channels that the specified user has moderator privileges in. +// Required scope: user:read:moderated_channels +func (c *Client) GetModeratedChannels(params *GetModeratedChannelsParams) (*GetModeratedChannelsResponse, error) { + if params.UserID == "" { + return nil, errors.New("user id is required") + } + + resp, err := c.get("/moderation/channels", &ManyModeratedChannels{}, params) + if err != nil { + return nil, err + } + + moderatedChannels := &GetModeratedChannelsResponse{} + resp.HydrateResponseCommon(&moderatedChannels.ResponseCommon) + moderatedChannels.Data.ModeratedChannels = resp.Data.(*ManyModeratedChannels).ModeratedChannels + moderatedChannels.Data.Pagination = resp.Data.(*ManyModeratedChannels).Pagination + + return moderatedChannels, nil +} + +type SendModeratorWarnChatMessageParams struct { + // The ID of the broadcaster whose chat room the message will be sent to + BroadcasterID string `query:"broadcaster_id"` + + // The ID of the twitch user who requested the warning. + ModeratorID string `query:"moderator_id"` + + // The ID of the user sent the WARN message + UserID string `json:"user_id"` + + // The warn message to send. + Reason string `json:"reason"` +} + +type ModeratorWarnChatMessage struct { + BroadcasterID string `json:"broadcaster_id"` + ModeratorID string `json:"moderator_id"` + UserID string `json:"user_id"` + Reason string `json:"reason"` +} + +type ManyModeratorWarnChatMessages struct { + Warnings []ModeratorWarnChatMessage `json:"data"` +} + +type SendModeratorWarnChatResponse struct { + ResponseCommon + + Data ManyModeratorWarnChatMessages +} + +// SendModeratorWarnMessage Sends a warning message to a user in the broadcaster’s chat. +// Required moderator:manage:warnings +func (c *Client) SendModeratorWarnMessage(params *SendModeratorWarnChatMessageParams) (*SendModeratorWarnChatResponse, error) { + if params.BroadcasterID == "" { + return nil, errors.New("error: broadcaster id must be specified") + } + if params.ModeratorID == "" { + return nil, errors.New("error: moderator id must be specified") + } + if params.UserID == "" { + return nil, errors.New("error: user id must be specified") + } + + resp, err := c.postAsJSON("moderation/warnings", &ManyModeratorWarnChatMessages{}, params) + if err != nil { + return nil, err + } + + messageResponse := &SendModeratorWarnChatResponse{} + resp.HydrateResponseCommon(&messageResponse.ResponseCommon) + messageResponse.Data.Warnings = resp.Data.(*ManyModeratorWarnChatMessages).Warnings + + return messageResponse, nil +} diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt index a01e4be..7b43ddf 100644 --- a/src/vendor/modules.txt +++ b/src/vendor/modules.txt @@ -130,7 +130,7 @@ github.com/jbenet/go-context/io # github.com/kevinburke/ssh_config v1.2.0 ## explicit github.com/kevinburke/ssh_config -# github.com/nicklaw5/helix/v2 v2.28.3 +# github.com/nicklaw5/helix/v2 v2.30.0 ## explicit; go 1.19 github.com/nicklaw5/helix/v2 # github.com/nikoksr/notify v0.41.0