Fix https://github.com/matthieugrieger/mumbledj/issues/26: nextsong showing incorrect info
This commit is contained in:
parent
8beb1322ba
commit
097b504947
|
@ -1,6 +1,9 @@
|
|||
MumbleDJ Changelog
|
||||
==================
|
||||
|
||||
### January 26, 2015 -- `v2.3.2`
|
||||
* Fixed !nextsong showing incorrect information about the next song in the queue.
|
||||
|
||||
### January 25, 2015 -- `v2.3.0, v2.3.1`
|
||||
* Added !currentsong command, which displays information about the song currently playing.
|
||||
* MumbleDJ now removes disconnected users from skiplists for playlists and songs within the SongQueue.
|
||||
|
|
|
@ -332,10 +332,10 @@ func numSongs() {
|
|||
// item if it exists. The user will then be sent a message containing the title and submitter
|
||||
// of the next item if it exists.
|
||||
func nextSong(user *gumble.User) {
|
||||
if title, submitter, err := dj.queue.PeekNext(); err != nil {
|
||||
if song, err := dj.queue.PeekNext(); err != nil {
|
||||
user.Send(NO_SONG_NEXT_MSG)
|
||||
} else {
|
||||
user.Send(fmt.Sprintf(NEXT_SONG_HTML, title, submitter))
|
||||
user.Send(fmt.Sprintf(NEXT_SONG_HTML, song.title, song.submitter))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
30
songqueue.go
30
songqueue.go
|
@ -53,26 +53,22 @@ func (q *SongQueue) NextItem() {
|
|||
q.queue = q.queue[1:]
|
||||
}
|
||||
|
||||
// Peeks at the next item and returns the title, submitter, and error status.
|
||||
func (q *SongQueue) PeekNext() (string, string, error) {
|
||||
var title, submitter string
|
||||
if q.Len() > 1 {
|
||||
if q.queue[1].ItemType() == "playlist" {
|
||||
title = q.queue[1].(*Playlist).songs.queue[0].(*Song).title
|
||||
submitter = q.queue[1].(*Playlist).submitter
|
||||
// Peeks at the next Song and returns it.
|
||||
func (q *SongQueue) PeekNext() (*Song, error) {
|
||||
if q.Len() != 0 {
|
||||
if q.CurrentItem().ItemType() == "playlist" {
|
||||
return q.CurrentItem().(*Playlist).songs.queue[1].(*Song), nil
|
||||
} else if q.Len() > 1 {
|
||||
if q.queue[1].ItemType() == "playlist" {
|
||||
return q.queue[1].(*Playlist).songs.queue[0].(*Song), nil
|
||||
} else {
|
||||
return q.queue[1].(*Song), nil
|
||||
}
|
||||
} else {
|
||||
title = q.queue[1].(*Song).title
|
||||
submitter = q.queue[1].(*Song).submitter
|
||||
return nil, errors.New("There is no song coming up next.")
|
||||
}
|
||||
return title, submitter, nil
|
||||
} else if q.Len() == 0 {
|
||||
return "", "", errors.New("There is no item next in the queue.")
|
||||
} else if q.CurrentItem().ItemType() == "playlist" {
|
||||
title = q.CurrentItem().(*Playlist).songs.queue[1].(*Song).title
|
||||
submitter = q.CurrentItem().(*Playlist).submitter
|
||||
return title, submitter, nil
|
||||
} else {
|
||||
return "", "", errors.New("There is no item next in the queue.")
|
||||
return nil, errors.New("There are no items in the queue.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue