Documentation ¶
Index ¶
- func CheckForDuplicateAliases() error
- func PerformStartupChecks()
- func ReadConfigFile() error
- func SetDefaultConfig()
- type Cache
- type MumbleDJ
- func (dj *MumbleDJ) Connect() error
- func (dj *MumbleDJ) FindAndExecuteCommand(user *gumble.User, message string) (string, bool, error)
- func (dj *MumbleDJ) GetService(url string) (interfaces.Service, error)
- func (dj *MumbleDJ) IsAdmin(user *gumble.User) bool
- func (dj *MumbleDJ) OnConnect(e *gumble.ConnectEvent)
- func (dj *MumbleDJ) OnDisconnect(e *gumble.DisconnectEvent)
- func (dj *MumbleDJ) OnTextMessage(e *gumble.TextMessageEvent)
- func (dj *MumbleDJ) OnUserChange(e *gumble.UserChangeEvent)
- func (dj *MumbleDJ) SendPrivateMessage(user *gumble.User, message string)
- type Playlist
- type Queue
- func (q *Queue) AppendTrack(t interfaces.Track) error
- func (q *Queue) CurrentTrack() (interfaces.Track, error)
- func (q *Queue) GetTrack(index int) interfaces.Track
- func (q *Queue) InsertTrack(i int, t interfaces.Track) error
- func (q *Queue) Length() int
- func (q *Queue) PauseCurrent() error
- func (q *Queue) PeekNextTrack() (interfaces.Track, error)
- func (q *Queue) PlayCurrent() error
- func (q *Queue) RandomNextTrack(queueWasEmpty bool)
- func (q *Queue) Reset()
- func (q *Queue) ResumeCurrent() error
- func (q *Queue) ShuffleTracks()
- func (q *Queue) Skip()
- func (q *Queue) SkipPlaylist()
- func (q *Queue) StopCurrent() error
- func (q *Queue) Traverse(visit func(i int, t interfaces.Track))
- type SkipTracker
- func (s *SkipTracker) AddPlaylistSkip(skipper *gumble.User) error
- func (s *SkipTracker) AddTrackSkip(skipper *gumble.User) error
- func (s *SkipTracker) NumPlaylistSkips() int
- func (s *SkipTracker) NumTrackSkips() int
- func (s *SkipTracker) RemovePlaylistSkip(skipper *gumble.User) error
- func (s *SkipTracker) RemoveTrackSkip(skipper *gumble.User) error
- func (s *SkipTracker) ResetPlaylistSkips()
- func (s *SkipTracker) ResetTrackSkips()
- type SortFilesByAge
- type Track
- func (t Track) GetAuthor() string
- func (t Track) GetAuthorURL() string
- func (t Track) GetDuration() time.Duration
- func (t Track) GetFilename() string
- func (t Track) GetID() string
- func (t Track) GetPlaybackOffset() time.Duration
- func (t Track) GetPlaylist() interfaces.Playlist
- func (t Track) GetService() string
- func (t Track) GetSubmitter() string
- func (t Track) GetThumbnailURL() string
- func (t Track) GetTitle() string
- func (t Track) GetURL() string
- type YouTubeDL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckForDuplicateAliases ¶
func CheckForDuplicateAliases() error
CheckForDuplicateAliases validates that all commands have unique aliases.
func PerformStartupChecks ¶
func PerformStartupChecks()
PerformStartupChecks executes the suite of startup checks that are run before the bot connects to the server.
func ReadConfigFile ¶
func ReadConfigFile() error
ReadConfigFile reads in the config file and updates the configuration accordingly.
func SetDefaultConfig ¶
func SetDefaultConfig()
SetDefaultConfig sets default values for all configuration options.
Types ¶
type Cache ¶
Cache keeps track of the filesize of the audio cache and provides methods for pruning the cache.
func (*Cache) CheckDirectorySize ¶
func (c *Cache) CheckDirectorySize()
CheckDirectorySize checks the cache directory to determine if the filesize of the files within exceed the user-specified size limit. If so, the oldest files are cleared until it is no longer exceeding the limit.
func (*Cache) CleanPeriodically ¶
func (c *Cache) CleanPeriodically()
CleanPeriodically loops forever, deleting expired cached audio files as necessary.
func (*Cache) DeleteOldest ¶
DeleteOldest deletes the oldest file in the cache.
func (*Cache) UpdateStatistics ¶
func (c *Cache) UpdateStatistics()
UpdateStatistics updates the statistics relevant to the cache (number of audio files cached, total current size of the cache).
type MumbleDJ ¶
type MumbleDJ struct { AvailableServices []interfaces.Service Client *gumble.Client GumbleConfig *gumble.Config TLSConfig *tls.Config AudioStream *gumbleffmpeg.Stream Queue interfaces.Queue Cache *Cache Skips interfaces.SkipTracker Commands []interfaces.Command Version string Volume float32 YouTubeDL *YouTubeDL KeepAlive chan bool }
MumbleDJ is a struct that keeps track of all aspects of the bot's state.
var DJ *MumbleDJ
DJ is a struct that keeps track of all aspects of MumbleDJ's environment.
func NewMumbleDJ ¶
func NewMumbleDJ() *MumbleDJ
NewMumbleDJ initializes and returns a MumbleDJ type.
func (*MumbleDJ) FindAndExecuteCommand ¶
FindAndExecuteCommand attempts to find a reference to a command in an incoming message. If found, the command is executed and the resulting message/error is returned.
func (*MumbleDJ) GetService ¶
func (dj *MumbleDJ) GetService(url string) (interfaces.Service, error)
GetService loops through the available services and determines if a URL matches a particular service. If a match is found, the service object is returned.
func (*MumbleDJ) IsAdmin ¶
IsAdmin checks whether a particular Mumble user is a MumbleDJ admin. Returns true if the user is an admin, and false otherwise.
func (*MumbleDJ) OnConnect ¶
func (dj *MumbleDJ) OnConnect(e *gumble.ConnectEvent)
OnConnect event. First moves MumbleDJ into the default channel if one exists. The configuration is loaded and the audio stream is initialized.
func (*MumbleDJ) OnDisconnect ¶
func (dj *MumbleDJ) OnDisconnect(e *gumble.DisconnectEvent)
OnDisconnect event. Terminates MumbleDJ process or retries connection if automatic connection retries are enabled.
func (*MumbleDJ) OnTextMessage ¶
func (dj *MumbleDJ) OnTextMessage(e *gumble.TextMessageEvent)
OnTextMessage event. Checks for command prefix and passes it to the Commander if it exists. Ignores the incoming message otherwise.
func (*MumbleDJ) OnUserChange ¶
func (dj *MumbleDJ) OnUserChange(e *gumble.UserChangeEvent)
OnUserChange event. Checks UserChange type and adjusts skip trackers to reflect the current status of the users on the server.
type Playlist ¶
Playlist stores all metadata related to a playlist of tracks.
func (*Playlist) GetService ¶
GetService returns the name of the service from which the playlist was retrieved from.
func (*Playlist) GetSubmitter ¶
GetSubmitter returns the submitter of the playlist.
type Queue ¶
type Queue struct { Queue []interfaces.Track // contains filtered or unexported fields }
Queue holds the audio queue itself along with useful methods for performing actions on the queue.
func (*Queue) AppendTrack ¶
func (q *Queue) AppendTrack(t interfaces.Track) error
AppendTrack adds a track to the back of the queue.
func (*Queue) CurrentTrack ¶
func (q *Queue) CurrentTrack() (interfaces.Track, error)
CurrentTrack returns the current Track.
func (*Queue) GetTrack ¶
func (q *Queue) GetTrack(index int) interfaces.Track
GetTrack takes an `index` argument to determine which track to return. If the track in position `index` exists, it is returned. Otherwise, nil is returned.
func (*Queue) InsertTrack ¶
func (q *Queue) InsertTrack(i int, t interfaces.Track) error
InsertTrack inserts track `t` at position `i` in the queue.
func (*Queue) PauseCurrent ¶
PauseCurrent pauses the current audio stream if it exists and is not already paused.
func (*Queue) PeekNextTrack ¶
func (q *Queue) PeekNextTrack() (interfaces.Track, error)
PeekNextTrack peeks at the next track and returns it.
func (*Queue) PlayCurrent ¶
PlayCurrent creates a new audio stream and begins playing the current track.
func (*Queue) RandomNextTrack ¶
RandomNextTrack sets a random track as the next track to be played.
func (*Queue) ResumeCurrent ¶
ResumeCurrent resumes playback of the current audio stream if it exists and is paused.
func (*Queue) ShuffleTracks ¶
func (q *Queue) ShuffleTracks()
ShuffleTracks shuffles the queue using an inside-out algorithm.
func (*Queue) Skip ¶
func (q *Queue) Skip()
Skip performs the necessary actions that take place when a track is skipped via a command.
func (*Queue) SkipPlaylist ¶
func (q *Queue) SkipPlaylist()
SkipPlaylist performs the necessary actions that take place when a playlist is skipped via a command.
func (*Queue) StopCurrent ¶
StopCurrent stops the playback of the current audio stream if it exists.
type SkipTracker ¶
type SkipTracker struct { TrackSkips []*gumble.User PlaylistSkips []*gumble.User // contains filtered or unexported fields }
SkipTracker keeps track of the list of users who have skipped the current track or playlist.
func NewSkipTracker ¶
func NewSkipTracker() *SkipTracker
NewSkipTracker returns an empty SkipTracker.
func (*SkipTracker) AddPlaylistSkip ¶
func (s *SkipTracker) AddPlaylistSkip(skipper *gumble.User) error
AddPlaylistSkip adds a skip to the SkipTracker for the current playlist.
func (*SkipTracker) AddTrackSkip ¶
func (s *SkipTracker) AddTrackSkip(skipper *gumble.User) error
AddTrackSkip adds a skip to the SkipTracker for the current track.
func (*SkipTracker) NumPlaylistSkips ¶
func (s *SkipTracker) NumPlaylistSkips() int
NumPlaylistSkips returns the number of users who have skipped the current playlist.
func (*SkipTracker) NumTrackSkips ¶
func (s *SkipTracker) NumTrackSkips() int
NumTrackSkips returns the number of users who have skipped the current track.
func (*SkipTracker) RemovePlaylistSkip ¶
func (s *SkipTracker) RemovePlaylistSkip(skipper *gumble.User) error
RemovePlaylistSkip removes a skip from the SkipTracker for the current playlist.
func (*SkipTracker) RemoveTrackSkip ¶
func (s *SkipTracker) RemoveTrackSkip(skipper *gumble.User) error
RemoveTrackSkip removes a skip from the SkipTracker for the current track.
func (*SkipTracker) ResetPlaylistSkips ¶
func (s *SkipTracker) ResetPlaylistSkips()
ResetPlaylistSkips resets the skip slice for the current playlist.
func (*SkipTracker) ResetTrackSkips ¶
func (s *SkipTracker) ResetTrackSkips()
ResetTrackSkips resets the skip slice for the current track.
type SortFilesByAge ¶
SortFilesByAge is a type that holds file information for cached items for sorting.
func (SortFilesByAge) Len ¶
func (a SortFilesByAge) Len() int
Len returns the length of the file slice.
func (SortFilesByAge) Less ¶
func (a SortFilesByAge) Less(i, j int) bool
Less compares two file modification times to determine if one is less than the other. Returns true if the item in index i is older than the item in index j, false otherwise.
func (SortFilesByAge) Swap ¶
func (a SortFilesByAge) Swap(i, j int)
Swap swaps two elements in the file slice.
type Track ¶
type Track struct { ID string URL string Title string Author string AuthorURL string Submitter string Service string Filename string ThumbnailURL string Duration time.Duration PlaybackOffset time.Duration Playlist interfaces.Playlist }
Track stores all metadata related to an audio track.
func (Track) GetAuthorURL ¶
GetAuthorURL returns the URL that links to the author of the track.
func (Track) GetDuration ¶
GetDuration returns the duration of the track.
func (Track) GetFilename ¶
GetFilename returns the name of the file stored on disk, if it exists. If no file on disk exists an empty string and error are returned.
func (Track) GetPlaybackOffset ¶
GetPlaybackOffset returns the playback offset for the track. A duration of 0 is given to tracks that do not specify an offset.
func (Track) GetPlaylist ¶
func (t Track) GetPlaylist() interfaces.Playlist
GetPlaylist returns the playlist the track is associated with, if it exists. If the track is not associated with a playlist a nil playlist and error are returned.
func (Track) GetService ¶
GetService returns the name of the service from which the track was retrieved from.
func (Track) GetSubmitter ¶
GetSubmitter returns the submitter of the track.
func (Track) GetThumbnailURL ¶
GetThumbnailURL returns the URL to the thumbnail for the track. If no thumbnail exists an empty string and error are returned.
type YouTubeDL ¶
type YouTubeDL struct{}
YouTubeDL is a struct that gathers all methods related to the youtube-dl software. youtube-dl: https://rg3.github.io/youtube-dl/