Fixing build issues

This commit is contained in:
MichaelOultram 2015-07-30 18:10:06 +01:00
parent 7b7bdd695c
commit dae87e41e7
4 changed files with 29 additions and 29 deletions

View file

@ -43,28 +43,28 @@ func parseCommand(user *gumble.User, username, command string) {
// Skip command // Skip command
case dj.conf.Aliases.SkipAlias: case dj.conf.Aliases.SkipAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminSkip) { if dj.HasPermission(username, dj.conf.Permissions.AdminSkip) {
skip(user, username, false, false) skip(user, false, false)
} else { } else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG) dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
} }
// Skip playlist command // Skip playlist command
case dj.conf.Aliases.SkipPlaylistAlias: case dj.conf.Aliases.SkipPlaylistAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminAddPlaylists) { if dj.HasPermission(username, dj.conf.Permissions.AdminAddPlaylists) {
skip(user, username, false, true) skip(user, false, true)
} else { } else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG) dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
} }
// Forceskip command // Forceskip command
case dj.conf.Aliases.AdminSkipAlias: case dj.conf.Aliases.AdminSkipAlias:
if dj.HasPermission(username, true) { if dj.HasPermission(username, true) {
skip(user, username, true, false) skip(user, true, false)
} else { } else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG) dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
} }
// Playlist forceskip command // Playlist forceskip command
case dj.conf.Aliases.AdminSkipPlaylistAlias: case dj.conf.Aliases.AdminSkipPlaylistAlias:
if dj.HasPermission(username, true) { if dj.HasPermission(username, true) {
skip(user, username, true, true) skip(user, true, true)
} else { } else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG) dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
} }
@ -78,7 +78,7 @@ func parseCommand(user *gumble.User, username, command string) {
// Volume command // Volume command
case dj.conf.Aliases.VolumeAlias: case dj.conf.Aliases.VolumeAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminVolume) { if dj.HasPermission(username, dj.conf.Permissions.AdminVolume) {
volume(user, username, argument) volume(user, argument)
} else { } else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG) 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 // 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. // 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 dj.audioStream.IsPlaying() {
if playlistSkip { if playlistSkip {
if dj.queue.CurrentSong().Playlist() != nil { 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 submitterSkipped := false
if admin { if admin {
dj.client.Self.Channel.Send(ADMIN_PLAYLIST_SKIP_MSG, false) dj.client.Self.Channel.Send(ADMIN_PLAYLIST_SKIP_MSG, false)
} else if dj.queue.CurrentSong().Submitter() == username { } else if dj.queue.CurrentSong().Submitter() == user.Name {
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SUBMITTER_SKIP_HTML, username), false) dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SUBMITTER_SKIP_HTML, user.Name), false)
submitterSkipped = true submitterSkipped = true
} else { } 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 { if submitterSkipped || dj.queue.CurrentSong().Playlist().SkipReached(len(dj.client.Self.Channel.Users)) || admin {
id := dj.queue.CurrentSong().Playlist().ID() 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) dj.SendPrivateMessage(user, NO_PLAYLIST_PLAYING_MSG)
} }
} else { } else {
if err := dj.queue.CurrentSong().AddSkip(username); err == nil { if err := dj.queue.CurrentSong().AddSkip(user.Name); err == nil {
submitterSkipped := false submitterSkipped := false
if admin { if admin {
dj.client.Self.Channel.Send(ADMIN_SONG_SKIP_MSG, false) dj.client.Self.Channel.Send(ADMIN_SONG_SKIP_MSG, false)
} else if dj.queue.CurrentSong().Submitter() == username { } else if dj.queue.CurrentSong().Submitter() == user.Name {
dj.client.Self.Channel.Send(fmt.Sprintf(SUBMITTER_SKIP_HTML, username), false) dj.client.Self.Channel.Send(fmt.Sprintf(SUBMITTER_SKIP_HTML, user.Name), false)
submitterSkipped = true submitterSkipped = true
} else { } 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 || dj.queue.CurrentSong().SkipReached(len(dj.client.Self.Channel.Users)) || admin {
if !(submitterSkipped || 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 // 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 // config to determine if the volume should be applied. If in the correct range, the new volume
// is applied and is immediately in effect. // is applied and is immediately in effect.
func volume(user *gumble.User, username, value string) { func volume(user *gumble.User, value string) {
if value == "" { if value == "" {
dj.client.Self.Channel.Send(fmt.Sprintf(CUR_VOLUME_HTML, dj.audioStream.Volume), false) dj.client.Self.Channel.Send(fmt.Sprintf(CUR_VOLUME_HTML, dj.audioStream.Volume), false)
} else { } else {
@ -259,7 +259,7 @@ func volume(user *gumble.User, username, value string) {
newVolume := float32(parsedVolume) newVolume := float32(parsedVolume)
if newVolume >= dj.conf.Volume.LowestVolume && newVolume <= dj.conf.Volume.HighestVolume { if newVolume >= dj.conf.Volume.LowestVolume && newVolume <= dj.conf.Volume.HighestVolume {
dj.audioStream.Volume = newVolume 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 { } else {
dj.SendPrivateMessage(user, fmt.Sprintf(NOT_IN_VOLUME_RANGE_MSG, dj.conf.Volume.LowestVolume, dj.conf.Volume.HighestVolume)) dj.SendPrivateMessage(user, fmt.Sprintf(NOT_IN_VOLUME_RANGE_MSG, dj.conf.Volume.LowestVolume, dj.conf.Volume.HighestVolume))
} }

View file

@ -12,13 +12,13 @@
function addURL() { function addURL() {
var url = $("#textbox"); var url = $("#textbox");
$.ajax(api("add") + "&value=" + url.attr("value")); $.ajax(api("add") + "&value=" + url.attr("value"));
url.value = ""; url.attr("value", "");
} }
function volume() { function volume() {
var volume = $("#textbox"); var volume = $("#textbox");
$.ajax(api("volume") + "&value=" + volume.attr("value")); $.ajax(api("volume") + "&value=" + volume.attr("value"));
volume.value = ""; volume.attr("value", "");
} }
function skip(val) { function skip(val) {

View file

@ -192,7 +192,7 @@ func (yt YouTube) NewSong(user, id, offset string, playlist *YouTubePlaylist) (*
dontSkip: false, dontSkip: false,
} }
dj.queue.AddSong(song) dj.queue.AddSong(song)
Verbose(song.Submitter() + " added track " + song.Title() + "\n") Verbose(song.Submitter() + " added track " + song.Title())
return song, nil return song, nil
} }
@ -245,16 +245,16 @@ func (s *YouTubeSong) Download() error {
// Checks to see if song is already downloaded // 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) { 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()) cmd := exec.Command("youtube-dl", "--output", fmt.Sprintf(`~/.mumbledj/songs/%s`, s.Filename()), "--format", "m4a", "--", s.ID())
if err := cmd.Run(); err == nil { if err := cmd.Run(); err == nil {
if dj.conf.Cache.Enabled { if dj.conf.Cache.Enabled {
dj.cache.CheckMaximumDirectorySize() dj.cache.CheckMaximumDirectorySize()
} }
Verbose(s.Title() + " downloaded\n") Verbose(s.Title() + " downloaded")
return nil return nil
} }
Verbose(s.Title() + " failed to download\n") Verbose(s.Title() + " failed to download")
return errors.New("Song download failed.") return errors.New("Song download failed.")
} }
return nil return nil
@ -307,7 +307,7 @@ func (s *YouTubeSong) Play() {
dj.client.Self.Channel.Send(fmt.Sprintf(message, s.Thumbnail(), s.ID(), dj.client.Self.Channel.Send(fmt.Sprintf(message, s.Thumbnail(), s.ID(),
s.Title(), s.Duration(), s.Submitter(), s.Playlist().Title()), false) s.Title(), s.Duration(), s.Submitter(), s.Playlist().Title()), false)
} }
Verbose("Now playing " + s.Title() + "\n") Verbose("Now playing " + s.Title())
go func() { go func() {
dj.audioStream.Wait() dj.audioStream.Wait()
@ -322,10 +322,10 @@ func (s *YouTubeSong) Delete() error {
filePath := fmt.Sprintf("%s/.mumbledj/songs/%s.m4a", dj.homeDir, s.ID()) filePath := fmt.Sprintf("%s/.mumbledj/songs/%s.m4a", dj.homeDir, s.ID())
if _, err := os.Stat(filePath); err == nil { if _, err := os.Stat(filePath); err == nil {
if err := os.Remove(filePath); err == nil { if err := os.Remove(filePath); err == nil {
Verbose("Deleted " + s.Title() + "\n") Verbose("Deleted " + s.Title())
return nil 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 errors.New("Error occurred while deleting audio file.")
} }
return nil return nil

8
web.go
View file

@ -80,8 +80,8 @@ func (web *WebServer) volume(w http.ResponseWriter, r *http.Request) {
if uname == nil { if uname == nil {
fmt.Fprintf(w, "Invalid Token") fmt.Fprintf(w, "Invalid Token")
} else { } else {
var url = html.UnescapeString(r.FormValue("value")) var volume = html.UnescapeString(r.FormValue("value"))
add(uname, url) volume(uname, volume)
} }
} }
@ -90,8 +90,8 @@ func (web *WebServer) skip(w http.ResponseWriter, r *http.Request) {
if uname == nil { if uname == nil {
fmt.Fprintf(w, "Invalid Token") fmt.Fprintf(w, "Invalid Token")
} else { } else {
var url = html.UnescapeString(r.FormValue("value")) var playlist = html.UnescapeString(r.FormValue("value"))
add(uname, url) skip(uname, false, playlist)
} }
} }