Documentation ¶
Index ¶
- Constants
- Variables
- func ErrIsDataRequestError(err error) bool
- func ErrIsUnknownResponse(err error) bool
- type AdvancePayload
- type Booth
- type ChatPayload
- type Config
- type ErrDataRequestError
- type ErrUnknownResponse
- type Event
- type HistoryItem
- type IntBool
- type Media
- type PlayScore
- type Playback
- type PlugDJ
- func (plug *PlugDJ) Close()
- func (plug *PlugDJ) Get(endpoint string) (*http.Response, error)
- func (plug *PlugDJ) GetData(endpoint string, data interface{}, meta interface{}) error
- func (plug *PlugDJ) JoinRoom(slug string) error
- func (plug *PlugDJ) ModerateDeleteMessage(messageID string) error
- func (plug *PlugDJ) Post(endpoint string, data map[string]string) (*http.Response, error)
- func (plug *PlugDJ) RegisterEvents(fn ProcessPayloadFunc, events ...Event)
- func (plug *PlugDJ) SendChat(msg string) error
- type ProcessPayloadFunc
- type Room
- type User
- type UserJoinPayload
- type UserLeavePayload
Constants ¶
View Source
const ( RegularChatMessage chatMessageType = iota EmoteChatMessage )
View Source
const ( AuthLoginEndpoint string = "/auth/login" ChatDeleteEndpoint string = "/chat/" HistoryEndpoint string = "/rooms/history" PlaylistEndpoint string = "/playlists" ModerateAddDJEndpoint string = "/booth/add" ModerateBanEndpoint string = "/bans/add" ModerateBoothEndpoint string = "/booth" ModerateMoveDJEndpoint string = "/booth/move" ModerateMuteEndpoint string = "/mutes" ModeratePermissionsEndpoint string = "/staff/update" ModerateRemoveDJEndpoint string = "/booth/remove/" ModerateSkipEndpoint string = "/booth/skip" ModerateStaffEndpoint string = "/staff/" ModerateUnbanEndpoint string = "/bans/" ModerateUnmuteEndpoint string = "/mutes/" SkipMeEndpoint string = "/booth/skip/me" RoomCycleBoothEndpoint string = "/booth/cycle" RoomLockBoothEndpoint string = "/booth/lock" RoomInfoEndpoint string = "/rooms/update" RoomJoinEndpoint string = "/rooms/join" RoomStateEndpoint string = "/rooms/state" UserInfoEndpoint string = "/users/me" UserGetAvatarsEndpoint string = "/store/inventory/avatars" UserSetAvatarEndpoint string = "/users/avatar" )
List of individual REST endpoints
Variables ¶
View Source
var ( ErrAuthentication = errors.New("plugapi: authentication failed") ErrAuthenticationRequired = errors.New("plugapi: authentication details required") ErrUnknownData = errors.New("plugapi: cannot structify request") )
General API errors
Functions ¶
func ErrIsDataRequestError ¶
func ErrIsUnknownResponse ¶
Types ¶
type AdvancePayload ¶
type Booth ¶
type Booth struct { CurrentDJ int `json:"currentDJ"` IsLocked bool `json:"isLocked"` // Can users join? ShouldCycle bool `json:"shouldCycle"` // Will the queue progress automatically? WaitingDJs []int `json:"waitingDJs"` }
Booth is the data about the current queue
type ChatPayload ¶
type ErrDataRequestError ¶
type ErrDataRequestError struct { Data interface{} Endpoint string }
func (ErrDataRequestError) Error ¶
func (e ErrDataRequestError) Error() string
type ErrUnknownResponse ¶
func (ErrUnknownResponse) Error ¶
func (e ErrUnknownResponse) Error() string
type Event ¶
type Event int
Event defines a Plug Event type
const ( AdvanceEvent Event = iota // = "advance" BanEvent // = "ban" BoothLockedEvent // = "boothLocked" ChatEvent // = "chat" ChatCommandEvent // = "command" ChatDeleteEvent // = "chatDelete" ChatLevelUpdateEvent // = "roomMinChatLevelUpdate" CommandEvent // = "command" DJListCycleEvent // = "djListCycle" DJListUpdateEvent // = "djListUpdate" DJListLockedEvent // = "djListLocked" EarnEvent // = "earn" FollowJoinEvent // = "followJoin" FloodChatEvent // = "floodChat" FriendRequestEvent // = "friendRequest" GiftedEvent // = "gifted" GrabEvent // = "grab" KillSessionEvent // = "killSession" MaintModeEvent // = "plugMaintenance" MaintModeAlertEvent // = "plugMaintenanceAlert" ModerateAddDjEvent // = "modAddDJ" ModerateAddWaitlistEvent // = "modAddWaitList" ModerateAmbassadorEvent // = "modAmbassador" ModerateBanEvent // = "modBan" ModerateMoveDjEvent // = "modMoveDJ" ModerateMuteEvent // = "modMute" ModerateRemoveDjEvent // = "modRemoveDJ" ModerateRemoveWaitlistEvent // = "modRemoveWaitList" ModerateSkipEvent // = "modSkip" ModerateStaffEvent // = "modStaff" NotifyEvent // = "notify" PdjMessageEvent // = "pdjMessage" PdjUpdateEvent // = "pdjUpdate" PingEvent // = "ping" PlaylistCycleEvent // = "playlistCycle" RequestDurationEvent // = "requestDuration" RequestDurationRetryEvent // = "requestDurationRetry" RoomChangeEvent // = "roomChanged" RoomDescriptionUpdateEvent // = "roomDescriptionUpdate" RoomJoinEvent // = "roomJoin" RoomNameUpdateEvent // = "roomNameUpdate" RoomVoteSkipEvent // = "roomVoteSkip" RoomWelcomeUpdateEvent // = "roomWelcomeUpdate" SessionCloseEvent // = "sessionClose" SkipEvent // = "skip" StrobeToggleEvent // = "strobeToggle" UserCounterUpdateEvent // = "userCounterUpdate" UserFollowEvent // = "userFollow" UserJoinEvent // = "userJoin" UserLeaveEvent // = "userLeave" UserUpdateEvent // = "userUpdate" VoteEvent // = "vote" )
List of Event types
type HistoryItem ¶
type HistoryItem struct { ID string `json:"id"` Media Media `json:"media"` Room struct { Name string `json:"name"` Slug string `json:"slug"` } `json:"room"` Score PlayScore `json:"score"` Timestamp string `json:"timestamp"` // Format: xx-xx-xx User struct { ID int `json:"id"` Username string `json:"username"` } }
HistoryItem is an individual item in the room history
type PlayScore ¶
type PlayScore struct { Grabs int `json:"grabs"` Listeners int `json:"listeners"` Negative int `json:"negative"` Positive int `json:"positive"` Skipped int `json:"skipped"` }
PlayScore is the score of an individual song
type Playback ¶
type Playback struct { HistoryID string `json:"historyID"` Media Media `json:"media"` PlaylistID int `json:"playlistID"` // default: -1 StartTime string `json:"startTime"` }
Playback metadata about an existing play (note, not the song)
type PlugDJ ¶
type PlugDJ struct { Room *Room History []HistoryItem User *User Log *log.Logger // contains filtered or unexported fields }
PlugDJ is the individual user connected to plug
func (*PlugDJ) ModerateDeleteMessage ¶
func (*PlugDJ) RegisterEvents ¶
func (plug *PlugDJ) RegisterEvents(fn ProcessPayloadFunc, events ...Event)
RegisterEvents registers the function to call when the specified event(s) are encountered Note: only one function can be registered to a single event - it will replace any existing handler.
type ProcessPayloadFunc ¶
type ProcessPayloadFunc func(plug *PlugDJ, payload interface{})
ProcessPayloadFunc is a common function for payload return values
type Room ¶
type Room struct { sync.RWMutex Booth Booth `json:"booth"` // FX interface{} `json:"fx"` // Grabs interface{} `json:"grabs"` Meta struct { Description string `json:"description"` Favorite bool `json:"favorite"` // Does the logged in user love this room? Guests int `json:"guests"` // Number of guests connected HostID int `json:"hostID"` // User ID of the room owner. default: -1 HostName string `json:"hostName"` // Username of the room owner ID int `json:"id"` // unique room identifier. default: -1 MinimumChatLevel int `json:"minChatLevel"` // power required to speak. default: 1 (POSITIVE 1) Name string `json:"name"` // name of the room Population int `json:"population"` // Number of real users in the room (guests excluded) Slug string `json:"slug"` // string shortname WelcomeMessage string `json:"welcomemessage"` // the welcome message on entering } `json:"meta"` // Mutes interface{} `json:"mutes"` Playback *Playback `json:"playback"` // contains filtered or unexported fields }
Room contains metadata about the room TODO: Unexport this.
type UserJoinPayload ¶
type UserJoinPayload struct{ User }
type UserLeavePayload ¶
type UserLeavePayload struct{ User }
Click to show internal directories.
Click to hide internal directories.