Finished add command
This commit is contained in:
parent
34eccd1630
commit
5161770cb1
17
commands.go
17
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, ""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = `
|
||||
<b>%s</b> has voted to skip this song.
|
||||
<b>%s</b> 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 <b>%g</b>.
|
||||
`
|
||||
|
||||
// Message shown to users when another user votes to skip the current song.
|
||||
const SKIP_ADDED_HTML = `
|
||||
<b>%s</b> has voted to skip the current song.
|
||||
`
|
||||
|
|
Reference in a new issue