diff --git a/commands.go b/commands.go index 4af0e58..353048d 100644 --- a/commands.go +++ b/commands.go @@ -33,11 +33,9 @@ func parseCommand(user *gumble.User, username, command string) { if argument == "" { user.Send(NO_ARGUMENT_MSG) } else { - success := add(username, argument) + success, songTitle := add(username, argument) if success { - fmt.Println("Add successful!") - // TODO: Replace this message with a more informative one. - dj.client.Self().Channel().Send(fmt.Sprintf("%s has added a song to the queue.", username), false) + dj.client.Self().Channel().Send(fmt.Sprintf(SONG_ADDED_HTML, username, songTitle), false) } else { user.Send(INVALID_URL_MSG) } @@ -117,7 +115,7 @@ func parseCommand(user *gumble.User, username, command string) { } } -func add(user, url string) bool { +func add(user, url string) (bool, string) { youtubePatterns := []string{ `https?:\/\/www\.youtube\.com\/watch\?v=([\w-]+)`, `https?:\/\/youtube\.com\/watch\?v=([\w-]+)`, @@ -140,13 +138,14 @@ func add(user, url string) bool { if matchFound { urlMatch := strings.Split(url, "=") shortUrl := urlMatch[1] - if dj.queue.AddSong(NewSong(user, shortUrl)) { - return true + newSong := NewSong(user, shortUrl) + if dj.queue.AddSong(newSong) { + return true, newSong.title } else { - return false + return false, "" } } else { - return false + return false, "" } } diff --git a/strings.go b/strings.go index a5d84e4..459816f 100644 --- a/strings.go +++ b/strings.go @@ -52,7 +52,7 @@ const NOW_PLAYING_HTML = ` // Message shown to channel when a song is added to the queue by a user. const SONG_ADDED_HTML = ` - %s has voted to skip this song. + %s has added "%s" to the queue. ` // Message shown to channel when a song has been skipped. @@ -64,3 +64,8 @@ const SONG_SKIPPED_HTML = ` const CUR_VOLUME_HTML = ` The current volume is %g. ` + +// Message shown to users when another user votes to skip the current song. +const SKIP_ADDED_HTML = ` + %s has voted to skip the current song. +`