Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/events/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TriggerCommand() (command *cobra.Command) {
command.Flags().StringVar(&websocketClient, "session", "", "Defines a specific websocket client/session to forward an event to. Used only with \"websocket\" transport.")
command.Flags().StringVar(&banStart, "ban-start", "", "Sets the timestamp a ban started at.")
command.Flags().StringVar(&banEnd, "ban-end", "", "Sets the timestamp a ban is intended to end at. If not set, the ban event will appear as permanent. This flag can take a timestamp or relative time (600, 600s, 10d4h12m55s)")
command.Flags().StringVar(&userInput, "user-input", "", "Sets the user input used for the event. Only applies to channel point redemptions.")

return
}
Expand Down Expand Up @@ -119,6 +120,7 @@ func triggerCmdRun(cmd *cobra.Command, args []string) error {
WebSocketClient: websocketClient,
BanStartTimestamp: banStart,
BanEndTimestamp: banEnd,
UserInput: userInput,
})

if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/events/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ var (
websocketClient string
banStart string
banEnd string
userInput string
)
1 change: 1 addition & 0 deletions docs/event.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ This command can take either the Event or Alias listed as an argument. It is pre
| `--timestamp` | | Sets the timestamp to be used in payloads and headers. Must be in RFC3339Nano format. | `--timestamp 2017-04-13T14:34:23` | N |
| `--to-user` | `-t` | Denotes the receiver's TUID of the event, usually the broadcaster. | `-t 44635596` | N |
| `--transport` | `-T` | The method used to send events. Can either be `webhook` or `websocket`. Default is `webhook`. | `-T webhook` | N |
| `--user-input` | | Sets the user input used for the event. Only applies to channel point redemptions. | `--user-input Awesome redemption!` | N |

**Examples**

Expand Down
1 change: 1 addition & 0 deletions internal/events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type MockEventParameters struct {
ClientID string
BanStartTimestamp string
BanEndTimestamp string
UserInput string
}

type MockEventResponse struct {
Expand Down
2 changes: 2 additions & 0 deletions internal/events/trigger/trigger_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type TriggerParameters struct {
WebSocketClient string
BanStartTimestamp string
BanEndTimestamp string
UserInput string
}

type TriggerResponse struct {
Expand Down Expand Up @@ -147,6 +148,7 @@ https://dev.twitch.tv/docs/eventsub/handling-webhook-events#processing-an-event`
GiftUser: p.GiftUser,
BanStartTimestamp: p.BanStartTimestamp,
BanEndTimestamp: p.BanEndTimestamp,
UserInput: p.UserInput,
}

e, err := types.GetByTriggerAndTransportAndVersion(p.Event, p.Transport, p.Version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
UserID: params.FromUserID,
UserLogin: params.FromUserName,
UserName: params.FromUserName,
UserInput: "Test Input From CLI",
UserInput: params.UserInput,
Status: params.EventStatus,
Reward: models.RedemptionReward{
ID: params.ItemID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestEventSub(t *testing.T) {
ItemID: "12345678-1234-abcd-5678-000000000000",
Cost: 1337,
ItemName: "Testing",
UserInput: "testing",
}

r, err := Event{}.GenerateEvent(params)
Expand All @@ -42,6 +43,7 @@ func TestEventSub(t *testing.T) {
a.Equal(params.Cost, body.Event.Reward.Cost)
a.Equal(params.ItemID, body.Event.Reward.ID)
a.Equal(params.ItemName, body.Event.Reward.Title)
a.Equal(params.UserInput, body.Event.UserInput)

params = events.MockEventParameters{
Transport: models.TransportWebhook,
Expand Down