Fixing build issues
This commit is contained in:
parent
7b7bdd695c
commit
dae87e41e7
32
commands.go
32
commands.go
|
@ -43,28 +43,28 @@ func parseCommand(user *gumble.User, username, command string) {
|
|||
// Skip command
|
||||
case dj.conf.Aliases.SkipAlias:
|
||||
if dj.HasPermission(username, dj.conf.Permissions.AdminSkip) {
|
||||
skip(user, username, false, false)
|
||||
skip(user, false, false)
|
||||
} else {
|
||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||
}
|
||||
// Skip playlist command
|
||||
case dj.conf.Aliases.SkipPlaylistAlias:
|
||||
if dj.HasPermission(username, dj.conf.Permissions.AdminAddPlaylists) {
|
||||
skip(user, username, false, true)
|
||||
skip(user, false, true)
|
||||
} else {
|
||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||
}
|
||||
// Forceskip command
|
||||
case dj.conf.Aliases.AdminSkipAlias:
|
||||
if dj.HasPermission(username, true) {
|
||||
skip(user, username, true, false)
|
||||
skip(user, true, false)
|
||||
} else {
|
||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||
}
|
||||
// Playlist forceskip command
|
||||
case dj.conf.Aliases.AdminSkipPlaylistAlias:
|
||||
if dj.HasPermission(username, true) {
|
||||
skip(user, username, true, true)
|
||||
skip(user, true, true)
|
||||
} else {
|
||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func parseCommand(user *gumble.User, username, command string) {
|
|||
// Volume command
|
||||
case dj.conf.Aliases.VolumeAlias:
|
||||
if dj.HasPermission(username, dj.conf.Permissions.AdminVolume) {
|
||||
volume(user, username, argument)
|
||||
volume(user, argument)
|
||||
} else {
|
||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||
}
|
||||
|
@ -177,19 +177,19 @@ func add(user *gumble.User, url string) error {
|
|||
|
||||
// skip performs !skip functionality. Adds a skip to the skippers slice for the current song, and then
|
||||
// evaluates if a skip should be performed. Both skip and forceskip are implemented here.
|
||||
func skip(user *gumble.User, username string, admin, playlistSkip bool) {
|
||||
func skip(user *gumble.User, admin, playlistSkip bool) {
|
||||
if dj.audioStream.IsPlaying() {
|
||||
if playlistSkip {
|
||||
if dj.queue.CurrentSong().Playlist() != nil {
|
||||
if err := dj.queue.CurrentSong().Playlist().AddSkip(username); err == nil {
|
||||
if err := dj.queue.CurrentSong().Playlist().AddSkip(user.Name); 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)
|
||||
} else if dj.queue.CurrentSong().Submitter() == user.Name {
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SUBMITTER_SKIP_HTML, user.Name), false)
|
||||
submitterSkipped = true
|
||||
} else {
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SKIP_ADDED_HTML, username), false)
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SKIP_ADDED_HTML, user.Name), false)
|
||||
}
|
||||
if submitterSkipped || dj.queue.CurrentSong().Playlist().SkipReached(len(dj.client.Self.Channel.Users)) || admin {
|
||||
id := dj.queue.CurrentSong().Playlist().ID()
|
||||
|
@ -218,15 +218,15 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) {
|
|||
dj.SendPrivateMessage(user, NO_PLAYLIST_PLAYING_MSG)
|
||||
}
|
||||
} else {
|
||||
if err := dj.queue.CurrentSong().AddSkip(username); err == nil {
|
||||
if err := dj.queue.CurrentSong().AddSkip(user.Name); 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)
|
||||
} else if dj.queue.CurrentSong().Submitter() == user.Name {
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(SUBMITTER_SKIP_HTML, user.Name), false)
|
||||
submitterSkipped = true
|
||||
} else {
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(SKIP_ADDED_HTML, username), false)
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(SKIP_ADDED_HTML, user.Name), false)
|
||||
}
|
||||
if submitterSkipped || dj.queue.CurrentSong().SkipReached(len(dj.client.Self.Channel.Users)) || admin {
|
||||
if !(submitterSkipped || admin) {
|
||||
|
@ -251,7 +251,7 @@ func help(user *gumble.User) {
|
|||
// volume performs !volume functionality. Checks input value against LowestVolume and HighestVolume from
|
||||
// config to determine if the volume should be applied. If in the correct range, the new volume
|
||||
// is applied and is immediately in effect.
|
||||
func volume(user *gumble.User, username, value string) {
|
||||
func volume(user *gumble.User, value string) {
|
||||
if value == "" {
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(CUR_VOLUME_HTML, dj.audioStream.Volume), false)
|
||||
} else {
|
||||
|
@ -259,7 +259,7 @@ func volume(user *gumble.User, username, value string) {
|
|||
newVolume := float32(parsedVolume)
|
||||
if newVolume >= dj.conf.Volume.LowestVolume && newVolume <= dj.conf.Volume.HighestVolume {
|
||||
dj.audioStream.Volume = newVolume
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(VOLUME_SUCCESS_HTML, username, dj.audioStream.Volume), false)
|
||||
dj.client.Self.Channel.Send(fmt.Sprintf(VOLUME_SUCCESS_HTML, user.Name, dj.audioStream.Volume), false)
|
||||
} else {
|
||||
dj.SendPrivateMessage(user, fmt.Sprintf(NOT_IN_VOLUME_RANGE_MSG, dj.conf.Volume.LowestVolume, dj.conf.Volume.HighestVolume))
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
function addURL() {
|
||||
var url = $("#textbox");
|
||||
$.ajax(api("add") + "&value=" + url.attr("value"));
|
||||
url.value = "";
|
||||
url.attr("value", "");
|
||||
}
|
||||
|
||||
function volume() {
|
||||
var volume = $("#textbox");
|
||||
$.ajax(api("volume") + "&value=" + volume.attr("value"));
|
||||
volume.value = "";
|
||||
volume.attr("value", "");
|
||||
}
|
||||
|
||||
function skip(val) {
|
||||
|
|
|
@ -192,7 +192,7 @@ func (yt YouTube) NewSong(user, id, offset string, playlist *YouTubePlaylist) (*
|
|||
dontSkip: false,
|
||||
}
|
||||
dj.queue.AddSong(song)
|
||||
Verbose(song.Submitter() + " added track " + song.Title() + "\n")
|
||||
Verbose(song.Submitter() + " added track " + song.Title())
|
||||
|
||||
return song, nil
|
||||
}
|
||||
|
@ -245,16 +245,16 @@ func (s *YouTubeSong) Download() error {
|
|||
|
||||
// Checks to see if song is already downloaded
|
||||
if _, err := os.Stat(fmt.Sprintf("%s/.mumbledj/songs/%s", dj.homeDir, s.Filename())); os.IsNotExist(err) {
|
||||
Verbose("Downloading " + s.Title() + "\n")
|
||||
Verbose("Downloading " + s.Title())
|
||||
cmd := exec.Command("youtube-dl", "--output", fmt.Sprintf(`~/.mumbledj/songs/%s`, s.Filename()), "--format", "m4a", "--", s.ID())
|
||||
if err := cmd.Run(); err == nil {
|
||||
if dj.conf.Cache.Enabled {
|
||||
dj.cache.CheckMaximumDirectorySize()
|
||||
}
|
||||
Verbose(s.Title() + " downloaded\n")
|
||||
Verbose(s.Title() + " downloaded")
|
||||
return nil
|
||||
}
|
||||
Verbose(s.Title() + " failed to download\n")
|
||||
Verbose(s.Title() + " failed to download")
|
||||
return errors.New("Song download failed.")
|
||||
}
|
||||
return nil
|
||||
|
@ -307,7 +307,7 @@ func (s *YouTubeSong) Play() {
|
|||
dj.client.Self.Channel.Send(fmt.Sprintf(message, s.Thumbnail(), s.ID(),
|
||||
s.Title(), s.Duration(), s.Submitter(), s.Playlist().Title()), false)
|
||||
}
|
||||
Verbose("Now playing " + s.Title() + "\n")
|
||||
Verbose("Now playing " + s.Title())
|
||||
|
||||
go func() {
|
||||
dj.audioStream.Wait()
|
||||
|
@ -322,10 +322,10 @@ func (s *YouTubeSong) Delete() error {
|
|||
filePath := fmt.Sprintf("%s/.mumbledj/songs/%s.m4a", dj.homeDir, s.ID())
|
||||
if _, err := os.Stat(filePath); err == nil {
|
||||
if err := os.Remove(filePath); err == nil {
|
||||
Verbose("Deleted " + s.Title() + "\n")
|
||||
Verbose("Deleted " + s.Title())
|
||||
return nil
|
||||
}
|
||||
Verbose("Failed to delete " + s.Title() + "\n")
|
||||
Verbose("Failed to delete " + s.Title())
|
||||
return errors.New("Error occurred while deleting audio file.")
|
||||
}
|
||||
return nil
|
||||
|
|
8
web.go
8
web.go
|
@ -80,8 +80,8 @@ func (web *WebServer) volume(w http.ResponseWriter, r *http.Request) {
|
|||
if uname == nil {
|
||||
fmt.Fprintf(w, "Invalid Token")
|
||||
} else {
|
||||
var url = html.UnescapeString(r.FormValue("value"))
|
||||
add(uname, url)
|
||||
var volume = html.UnescapeString(r.FormValue("value"))
|
||||
volume(uname, volume)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ func (web *WebServer) skip(w http.ResponseWriter, r *http.Request) {
|
|||
if uname == nil {
|
||||
fmt.Fprintf(w, "Invalid Token")
|
||||
} else {
|
||||
var url = html.UnescapeString(r.FormValue("value"))
|
||||
add(uname, url)
|
||||
var playlist = html.UnescapeString(r.FormValue("value"))
|
||||
skip(uname, false, playlist)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue