Documentation ¶
Overview ¶
Package webhook provides support for PluralKit's dispatch webhooks.
Index ¶
- Constants
- Variables
- type CreateGroupEventData
- type CreateMemberEventData
- type CreateMessageEventData
- type CreateSwitchEventData
- type DeleteAllSwitchesEventData
- type DeleteGroupEventData
- type DeleteMemberEventData
- type DeleteSwitchEventData
- type DispatchEventType
- type Event
- type LinkAccountEventData
- type PingEventData
- type SuccessfulImportEventData
- type TokenGetter
- type UnknownEventData
- type UnlinkAccountEventData
- type UpdateGroupEventData
- type UpdateMemberEventData
- type UpdateMemberGuildEventData
- type UpdateSettingsEventData
- type UpdateSwitchEventData
- type UpdateSystemEventData
- type UpdateSystemGuildEventData
- type WebhookEvent
Constants ¶
const ErrInvalidToken = errors.Sentinel("payload token doesn't match")
Variables ¶
var EventCreators = map[DispatchEventType]func() Event{ PingEventType: func() Event { return new(PingEventData) }, CreateSwitchEventType: func() Event { return new(CreateSwitchEventData) }, UpdateSystemEventType: func() Event { return new(UpdateSystemEventData) }, UpdateSettingsEventType: func() Event { return new(UpdateSettingsEventData) }, CreateMemberEventType: func() Event { return new(CreateMemberEventData) }, UpdateMemberEventType: func() Event { return new(UpdateMemberEventData) }, DeleteMemberEventType: func() Event { return new(DeleteMemberEventData) }, CreateGroupEventType: func() Event { return new(CreateGroupEventData) }, UpdateGroupEventType: func() Event { return new(UpdateGroupEventData) }, DeleteGroupEventType: func() Event { return new(DeleteGroupEventData) }, LinkAccountEventType: func() Event { return new(LinkAccountEventData) }, UnlinkAccountEventType: func() Event { return new(UnlinkAccountEventData) }, UpdateSystemGuildEventType: func() Event { return new(UpdateSystemGuildEventData) }, UpdateMemberGuildEventType: func() Event { return new(UpdateMemberGuildEventData) }, CreateMessageEventType: func() Event { return new(CreateMessageEventData) }, UpdateSwitchEventType: func() Event { return new(UpdateSwitchEventData) }, DeleteSwitchEventType: func() Event { return new(DeleteSwitchEventData) }, DeleteAllSwitchesEventType: func() Event { return new(DeleteAllSwitchesEventData) }, SuccessfulImportEventType: func() Event { return new(SuccessfulImportEventData) }, }
EventCreators are funcs used to create Event structs to unmarshal to.
Functions ¶
This section is empty.
Types ¶
type CreateGroupEventData ¶
type CreateGroupEventData struct {
Name string `json:"name"`
}
func (*CreateGroupEventData) Type ¶
func (*CreateGroupEventData) Type() DispatchEventType
type CreateMemberEventData ¶
type CreateMemberEventData struct {
Name string `json:"name"`
}
func (*CreateMemberEventData) Type ¶
func (*CreateMemberEventData) Type() DispatchEventType
type CreateMessageEventData ¶
type CreateMessageEventData struct {
pkgo.Message
}
func (*CreateMessageEventData) Type ¶
func (*CreateMessageEventData) Type() DispatchEventType
type CreateSwitchEventData ¶
type CreateSwitchEventData struct {
pkgo.Switch
}
func (*CreateSwitchEventData) Type ¶
func (*CreateSwitchEventData) Type() DispatchEventType
type DeleteAllSwitchesEventData ¶
type DeleteAllSwitchesEventData struct{}
func (*DeleteAllSwitchesEventData) Type ¶
func (*DeleteAllSwitchesEventData) Type() DispatchEventType
type DeleteGroupEventData ¶
type DeleteGroupEventData struct{}
func (*DeleteGroupEventData) Type ¶
func (*DeleteGroupEventData) Type() DispatchEventType
type DeleteMemberEventData ¶
type DeleteMemberEventData struct{}
func (*DeleteMemberEventData) Type ¶
func (*DeleteMemberEventData) Type() DispatchEventType
type DeleteSwitchEventData ¶
type DeleteSwitchEventData struct{}
func (*DeleteSwitchEventData) Type ¶
func (*DeleteSwitchEventData) Type() DispatchEventType
type DispatchEventType ¶
type DispatchEventType string
const ( UnknownEventType DispatchEventType = "" PingEventType DispatchEventType = "PING" UpdateSystemEventType DispatchEventType = "UPDATE_SYSTEM" UpdateSettingsEventType DispatchEventType = "UPDATE_SETTINGS" CreateMemberEventType DispatchEventType = "CREATE_MEMBER" UpdateMemberEventType DispatchEventType = "UPDATE_MEMBER" DeleteMemberEventType DispatchEventType = "DELETE_MEMBER" CreateGroupEventType DispatchEventType = "CREATE_GROUP" UpdateGroupEventType DispatchEventType = "UPDATE_GROUP" UpdateGroupMembersEventType DispatchEventType = "UPDATE_GROUP_MEMBERS" DeleteGroupEventType DispatchEventType = "DELETE_GROUP" LinkAccountEventType DispatchEventType = "LINK_ACCOUNT" UnlinkAccountEventType DispatchEventType = "UNLINK_ACCOUNT" UpdateSystemGuildEventType DispatchEventType = "UPDATE_SYSTEM_GUILD" UpdateMemberGuildEventType DispatchEventType = "UPDATE_MEMBER_GUILD" CreateMessageEventType DispatchEventType = "CREATE_MESSAGE" CreateSwitchEventType DispatchEventType = "CREATE_SWITCH" UpdateSwitchEventType DispatchEventType = "UPDATE_SWITCH" UpdateSwitchMembersEventType DispatchEventType = "UPDATE_SWITCH_MEMBERS" DeleteSwitchEventType DispatchEventType = "DELETE_SWITCH" DeleteAllSwitchesEventType DispatchEventType = "DELETE_ALL_SWITCHES" SuccessfulImportEventType DispatchEventType = "SUCCESSFUL_IMPORT" )
type Event ¶
type Event interface {
Type() DispatchEventType
}
type LinkAccountEventData ¶
type LinkAccountEventData struct{}
func (*LinkAccountEventData) Type ¶
func (*LinkAccountEventData) Type() DispatchEventType
type PingEventData ¶
type PingEventData struct{}
func (*PingEventData) Type ¶
func (*PingEventData) Type() DispatchEventType
type SuccessfulImportEventData ¶
type SuccessfulImportEventData struct{}
func (*SuccessfulImportEventData) Type ¶
func (*SuccessfulImportEventData) Type() DispatchEventType
type TokenGetter ¶
TokenGetter is a function used to get a signing token for the given system ID. If it returns an error, unmarshaling is aborted.
type UnknownEventData ¶
type UnknownEventData struct {
json.RawMessage
}
func (*UnknownEventData) Type ¶
func (*UnknownEventData) Type() DispatchEventType
type UnlinkAccountEventData ¶
type UnlinkAccountEventData struct{}
func (*UnlinkAccountEventData) Type ¶
func (*UnlinkAccountEventData) Type() DispatchEventType
type UpdateGroupEventData ¶
type UpdateGroupEventData struct { Name *string `json:"name,omitempty"` DisplayName *string `json:"display_name,omitempty"` Description *string `json:"description,omitempty"` Icon *string `json:"icon,omitempty"` Banner *string `json:"banner,omitempty"` Color *pkgo.Color `json:"color,omitempty"` Privacy *pkgo.GroupPrivacy `json:"privacy,omitempty"` }
func (*UpdateGroupEventData) Type ¶
func (*UpdateGroupEventData) Type() DispatchEventType
type UpdateMemberEventData ¶
type UpdateMemberEventData struct { Name *string `json:"name,omitempty"` DisplayName *string `json:"display_name,omitempty"` Color *pkgo.Color `json:"color,omitempty"` Birthday *pkgo.Birthday `json:"birthday,omitempty"` Pronouns *string `json:"pronouns,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` Banner *string `json:"banner,omitempty"` Description *string `json:"description,omitempty"` ProxyTags *[]pkgo.ProxyTag `json:"proxy_tags,omitempty"` KeepProxy *bool `json:"keep_proxy"` Privacy *pkgo.MemberPrivacy `json:"privacy,omitempty"` }
func (*UpdateMemberEventData) Type ¶
func (*UpdateMemberEventData) Type() DispatchEventType
type UpdateMemberGuildEventData ¶
type UpdateMemberGuildEventData struct { GuildID pkgo.Snowflake `json:"guild_id"` DisplayName *string `json:"display_name,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` }
func (*UpdateMemberGuildEventData) Type ¶
func (*UpdateMemberGuildEventData) Type() DispatchEventType
type UpdateSettingsEventData ¶
type UpdateSettingsEventData struct { Timezone *string `json:"timezone,omitempty"` PingsEnabled *bool `json:"pings_enabled,omitempty"` LatchTimeout *int `json:"latch_timeout,omitempty"` MemberDefaultPrivate *bool `json:"member_default_private,omitempty"` GroupDefaultPrivate *bool `json:"group_default_private,omitempty"` ShowPrivateInfo *bool `json:"show_private_info,omitempty"` MemberLimit *int `json:"member_limit,omitempty"` GroupLimit *int `json:"group_limit,omitempty"` }
func (*UpdateSettingsEventData) Type ¶
func (*UpdateSettingsEventData) Type() DispatchEventType
type UpdateSwitchEventData ¶
type UpdateSwitchEventData struct { Timestamp *time.Time `json:"timestamp,omitempty"` Members *[]string `json:"members,omitempty"` }
func (*UpdateSwitchEventData) Type ¶
func (*UpdateSwitchEventData) Type() DispatchEventType
type UpdateSystemEventData ¶
type UpdateSystemEventData struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` Tag *string `json:"tag,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` Banner *string `json:"banner,omitempty"` Color *string `json:"color,omitempty"` Privacy *pkgo.SystemPrivacy `json:"privacy,omitempty"` }
func (*UpdateSystemEventData) Type ¶
func (*UpdateSystemEventData) Type() DispatchEventType
type UpdateSystemGuildEventData ¶
type UpdateSystemGuildEventData struct { GuildID pkgo.Snowflake `json:"guild_id"` ProxyingEnabled *bool `json:"proxying_enabled,omitempty"` AutoproxyMode *pkgo.AutoproxyMode `json:"autoproxy_mode,omitempty"` AutoproxyMember *string `json:"autoproxy_member,omitempty"` Tag *string `json:"tag,omitempty"` TagEnabled *bool `json:"tag_enabled,omitempty"` }
func (*UpdateSystemGuildEventData) Type ¶
func (*UpdateSystemGuildEventData) Type() DispatchEventType
type WebhookEvent ¶
type WebhookEvent struct { Type DispatchEventType `json:"type"` Token string `json:"signing_token"` SystemID uuid.UUID `json:"system_id"` EntityID string `json:"id,omitempty"` GuildID pkgo.Snowflake `json:"guild_id,omitempty"` // Raw is the raw JSON data. Raw json.RawMessage `json:"data"` // Data is the unmarshalled dispatch event payload. // Type assertions should be made on this value. // All types in this value are *pointer* types. // Unknown events are unmarshalled as UnknownEventPayload Data Event `json:"-"` }
func Decode ¶
func Decode(r io.Reader, tkn TokenGetter) (ev WebhookEvent, err error)
Unmarshal unmarshals the given io.Reader to a WebhookEvent, and also validates the token if tkn is not nil. If the token returned by tkn is empty, the event is *not* validated.
func Unmarshal ¶
func Unmarshal(src []byte, tkn TokenGetter) (ev WebhookEvent, err error)
Unmarshal unmarshals the given byte slice to a WebhookEvent, and also validates the token if tkn is not nil. If the token returned by tkn is empty, the event is *not* validated.
func (WebhookEvent) Snowflake ¶
func (ev WebhookEvent) Snowflake() (pkgo.Snowflake, error)
Snowflake tries parsing the event's entity ID into an account ID