From 23937271370e1f7bf2b49f7a4efdb06a67ee0d48 Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Fri, 20 Mar 2015 21:35:19 -0700 Subject: [PATCH] Song/playlist is now skipped when submitter skips --- commands.go | 20 ++++++++++++++++---- strings.go | 10 ++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/commands.go b/commands.go index 59de3b4..f1bf524 100644 --- a/commands.go +++ b/commands.go @@ -241,12 +241,16 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) { if playlistSkip { if dj.queue.CurrentSong().playlist != nil { if err := dj.queue.CurrentSong().playlist.AddSkip(username); err == nil { + submitterSkipped := false if admin { dj.client.Self.Channel.Send(ADMIN_PLAYLIST_SKIP_MSG, false) + } else if dj.queue.CurrentSong().submitter == username { + dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SUBMITTER_SKIP_HTML, username), false) + submitterSkipped = true } else { dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SKIP_ADDED_HTML, username), false) } - if dj.queue.CurrentSong().playlist.SkipReached(len(dj.client.Self.Channel.Users)) || admin { + if submitterSkipped || dj.queue.CurrentSong().playlist.SkipReached(len(dj.client.Self.Channel.Users)) || admin { id := dj.queue.CurrentSong().playlist.id dj.queue.CurrentSong().playlist.DeleteSkippers() for i := 0; i < len(dj.queue.queue); i++ { @@ -261,7 +265,9 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) { // Set dontSkip to true to avoid audioStream.Stop() callback skipping the new first song. dj.queue.CurrentSong().dontSkip = true } - dj.client.Self.Channel.Send(PLAYLIST_SKIPPED_HTML, false) + if !(submitterSkipped || admin) { + dj.client.Self.Channel.Send(PLAYLIST_SKIPPED_HTML, false) + } if err := dj.audioStream.Stop(); err != nil { panic(errors.New("An error occurred while stopping the current song.")) } @@ -272,13 +278,19 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) { } } else { if err := dj.queue.CurrentSong().AddSkip(username); err == nil { + submitterSkipped := false if admin { dj.client.Self.Channel.Send(ADMIN_SONG_SKIP_MSG, false) + } else if dj.queue.CurrentSong().submitter == username { + dj.client.Self.Channel.Send(fmt.Sprintf(SUBMITTER_SKIP_HTML, username), false) + submitterSkipped = true } else { dj.client.Self.Channel.Send(fmt.Sprintf(SKIP_ADDED_HTML, username), false) } - if dj.queue.CurrentSong().SkipReached(len(dj.client.Self.Channel.Users)) || admin { - dj.client.Self.Channel.Send(SONG_SKIPPED_HTML, false) + if submitterSkipped || dj.queue.CurrentSong().SkipReached(len(dj.client.Self.Channel.Users)) || admin { + if !(submitterSkipped || admin) { + dj.client.Self.Channel.Send(SONG_SKIPPED_HTML, false) + } if err := dj.audioStream.Stop(); err != nil { panic(errors.New("An error occurred while stopping the current song.")) } diff --git a/strings.go b/strings.go index 3a43444..e9e3855 100644 --- a/strings.go +++ b/strings.go @@ -155,11 +155,21 @@ const SKIP_ADDED_HTML = ` %s has voted to skip the current song. ` +// Message shown to users when the submitter of a song decides to skip their song. +const SUBMITTER_SKIP_HTML = ` + The current song has been skipped by %s, the submitter. +` + // Message shown to users when another user votes to skip the current playlist. const PLAYLIST_SKIP_ADDED_HTML = ` %s has voted to skip the current playlist. ` +// Message shown to users when the submitter of a song decides to skip their song. +const PLAYLIST_SUBMITTER_SKIP_HTML = ` + The current playlist has been skipped by %s, the submitter. +` + // Message shown to users when they successfully change the volume. const VOLUME_SUCCESS_HTML = ` %s has changed the volume to %.2f.