package messages import ( "time" "go.fifitido.net/twitch/api/eventsub" ) type Message struct { // An ID that uniquely identifies this message. // This is an opaque ID, and is not required to be in any particular format. Id string // Twitch sends you a notification at least once. // If Twitch is unsure of whether you received a notification, it’ll resend the event, which means you may receive a notification twice. // If this is an issue for your implementation, see Handling duplicates for options: https://dev.twitch.tv/docs/eventsub#handling-duplicate-events Retry string // The type of notification. Type Type // The HMAC signature that you use to verify that Twitch sent the message. // See Verifying the event message: https://dev.twitch.tv/docs/eventsub/handling-webhook-events/#verifying-the-event-message Signature string // The UTC date and time (in RFC3339 format) that Twitch sent the notification. Timestamp time.Time // The subscription type you subscribed to. For example, channel.follow. SubscriptionType *eventsub.SubscriptionType // The message data. // // For TypeNotification, this will be a Notification. // // For TypeWebhookCallbackVerification, this will be a WebhookCallbackVerification. // // For TypeRevocation, this will be a Revocation. Data any } type Type string const ( // notification — Contains the event's data. // See Processing an event: https://dev.twitch.tv/docs/eventsub/handling-webhook-events/#processing-an-event TypeNotification Type = "notification" // webhook_callback_verification — Contains the challenge used to verify that you own the event handler. // See Responding to a challenge request: https://dev.twitch.tv/docs/eventsub/handling-webhook-events/#responding-to-a-challenge-request TypeWebhookCallbackVerification Type = "webhook_callback_verification" // revocation — Contains the reason why Twitch revoked your subscription. // See Revoking your subscription: https://dev.twitch.tv/docs/eventsub/handling-webhook-events/#revoking-your-subscription TypeRevocation Type = "revocation" ) type Subscription struct { // Your client ID. Id string `json:"id"` // The notification’s subscription type. Type string `json:"type"` // The version of the subscription. Version string `json:"version"` // The status of the subscription. Status string `json:"status"` // How much the subscription counts against your limit. See Subscription Limits for more information. Cost int `json:"cost"` // Subscription-specific parameters. Condition map[string]any `json:"condition"` // The time the notification was created. CreatedAt string `json:"created_at"` } type Notification struct { // Metadata about the subscription. Subscription Subscription `json:"subscription"` // The notification’s event data.. Event any `json:"event"` } type Revocation struct { // Metadata about the subscription. Subscription Subscription `json:"subscription"` } type WebhookCallbackVerification struct { // The challenge. Challenge string `json:"challenge"` // Metadata about the subscription. Subscription Subscription `json:"subscription"` }