commit
7b9086c0f7
37
commands.go
37
commands.go
|
@ -8,6 +8,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -162,14 +163,14 @@ func parseCommand(user *gumble.User, username, command string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shuffleon command
|
// Shuffleon command
|
||||||
case dj.conf.Aliases.ShuffleOnAlias:
|
case dj.conf.Aliases.ShuffleOnAlias:
|
||||||
if dj.HasPermission(username, dj.conf.Permissions.AdminShuffleToggle) {
|
if dj.HasPermission(username, dj.conf.Permissions.AdminShuffleToggle) {
|
||||||
toggleAutomaticShuffle(true, user, username)
|
toggleAutomaticShuffle(true, user, username)
|
||||||
} else {
|
} else {
|
||||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shuffleoff command
|
// Shuffleoff command
|
||||||
case dj.conf.Aliases.ShuffleOffAlias:
|
case dj.conf.Aliases.ShuffleOffAlias:
|
||||||
if dj.HasPermission(username, dj.conf.Permissions.AdminShuffleToggle) {
|
if dj.HasPermission(username, dj.conf.Permissions.AdminShuffleToggle) {
|
||||||
toggleAutomaticShuffle(false, user, username)
|
toggleAutomaticShuffle(false, user, username)
|
||||||
|
@ -177,6 +178,13 @@ func parseCommand(user *gumble.User, username, command string) {
|
||||||
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListSongs command
|
||||||
|
case dj.conf.Aliases.ListSongsAlias:
|
||||||
|
if dj.HasPermission(username, dj.conf.Permissions.AdminListSongs) {
|
||||||
|
listSongs(user)
|
||||||
|
} else {
|
||||||
|
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
dj.SendPrivateMessage(user, COMMAND_DOESNT_EXIST_MSG)
|
dj.SendPrivateMessage(user, COMMAND_DOESNT_EXIST_MSG)
|
||||||
}
|
}
|
||||||
|
@ -428,17 +436,30 @@ func shuffleSongs(user *gumble.User, username string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles toggling of automatic shuffle playing
|
// handles toggling of automatic shuffle playing
|
||||||
func toggleAutomaticShuffle(activate bool, user *gumble.User, username string){
|
func toggleAutomaticShuffle(activate bool, user *gumble.User, username string) {
|
||||||
if (dj.conf.General.AutomaticShuffleOn != activate){
|
if dj.conf.General.AutomaticShuffleOn != activate {
|
||||||
dj.conf.General.AutomaticShuffleOn = activate
|
dj.conf.General.AutomaticShuffleOn = activate
|
||||||
if (activate){
|
if activate {
|
||||||
dj.client.Self.Channel.Send(fmt.Sprintf(SHUFFLE_ON_MESSAGE, username), false)
|
dj.client.Self.Channel.Send(fmt.Sprintf(SHUFFLE_ON_MESSAGE, username), false)
|
||||||
} else{
|
} else {
|
||||||
dj.client.Self.Channel.Send(fmt.Sprintf(SHUFFLE_OFF_MESSAGE, username), false)
|
dj.client.Self.Channel.Send(fmt.Sprintf(SHUFFLE_OFF_MESSAGE, username), false)
|
||||||
}
|
}
|
||||||
} else if (activate){
|
} else if activate {
|
||||||
dj.SendPrivateMessage(user, SHUFFLE_ACTIVATED_ERROR_MESSAGE)
|
dj.SendPrivateMessage(user, SHUFFLE_ACTIVATED_ERROR_MESSAGE)
|
||||||
} else{
|
} else {
|
||||||
dj.SendPrivateMessage(user, SHUFFLE_DEACTIVATED_ERROR_MESSAGE)
|
dj.SendPrivateMessage(user, SHUFFLE_DEACTIVATED_ERROR_MESSAGE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// listSongs handles !listSongs functionality. Sends a private message to the user a list of all songs in the queue
|
||||||
|
func listSongs(user *gumble.User) {
|
||||||
|
if dj.audioStream.IsPlaying() {
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
dj.queue.Traverse(func(i int, song Song) {
|
||||||
|
buffer.WriteString(fmt.Sprintf(SONG_LIST_HTML, song.Title(), song.Submitter()))
|
||||||
|
})
|
||||||
|
dj.SendPrivateMessage(user, buffer.String())
|
||||||
|
} else {
|
||||||
|
dj.SendPrivateMessage(user, NO_MUSIC_PLAYING_MSG)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -146,6 +146,10 @@ ShuffleOnAlias = "shuffleon"
|
||||||
# DEFAULT VALUE: "shuffleoff"
|
# DEFAULT VALUE: "shuffleoff"
|
||||||
ShuffleOffAlias = "shuffleoff"
|
ShuffleOffAlias = "shuffleoff"
|
||||||
|
|
||||||
|
# Alias used for listsongs command
|
||||||
|
# DEFAULT_VALUE: "listsongs"
|
||||||
|
ListSongsAlias = "listsongs"
|
||||||
|
|
||||||
[Permissions]
|
[Permissions]
|
||||||
|
|
||||||
# Enable admins
|
# Enable admins
|
||||||
|
@ -225,6 +229,9 @@ AdminKill = true
|
||||||
# DEFAULT VALUE: true
|
# DEFAULT VALUE: true
|
||||||
AdminShuffle = true
|
AdminShuffle = true
|
||||||
|
|
||||||
|
# Make listSongs an admin command?
|
||||||
|
# DEFAULT VALUE: false
|
||||||
|
AdminListSongs = false
|
||||||
|
|
||||||
# Make shuffleon and shuffleoff admin commands?
|
# Make shuffleon and shuffleoff admin commands?
|
||||||
# DEFAULT VALUE: true
|
# DEFAULT VALUE: true
|
||||||
|
|
1
main.go
1
main.go
|
@ -136,7 +136,6 @@ func CheckAPIKeys() {
|
||||||
anyDisabled := false
|
anyDisabled := false
|
||||||
|
|
||||||
// Checks YouTube API key
|
// Checks YouTube API key
|
||||||
|
|
||||||
if dj.conf.ServiceKeys.Youtube == "" {
|
if dj.conf.ServiceKeys.Youtube == "" {
|
||||||
anyDisabled = true
|
anyDisabled = true
|
||||||
fmt.Printf("The youtube service has been disabled as you do not have a YouTube API key defined in your config file!\n")
|
fmt.Printf("The youtube service has been disabled as you do not have a YouTube API key defined in your config file!\n")
|
||||||
|
|
|
@ -17,13 +17,13 @@ import (
|
||||||
// DjConfig is a Golang struct representation of mumbledj.gcfg file structure for parsing.
|
// DjConfig is a Golang struct representation of mumbledj.gcfg file structure for parsing.
|
||||||
type DjConfig struct {
|
type DjConfig struct {
|
||||||
General struct {
|
General struct {
|
||||||
CommandPrefix string
|
CommandPrefix string
|
||||||
SkipRatio float32
|
SkipRatio float32
|
||||||
PlaylistSkipRatio float32
|
PlaylistSkipRatio float32
|
||||||
DefaultComment string
|
DefaultComment string
|
||||||
MaxSongDuration int
|
MaxSongDuration int
|
||||||
MaxSongPerPlaylist int
|
MaxSongPerPlaylist int
|
||||||
AutomaticShuffleOn bool
|
AutomaticShuffleOn bool
|
||||||
}
|
}
|
||||||
Cache struct {
|
Cache struct {
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
@ -56,31 +56,33 @@ type DjConfig struct {
|
||||||
ShuffleAlias string
|
ShuffleAlias string
|
||||||
ShuffleOnAlias string
|
ShuffleOnAlias string
|
||||||
ShuffleOffAlias string
|
ShuffleOffAlias string
|
||||||
|
ListSongsAlias string
|
||||||
}
|
}
|
||||||
Permissions struct {
|
Permissions struct {
|
||||||
AdminsEnabled bool
|
AdminsEnabled bool
|
||||||
Admins []string
|
Admins []string
|
||||||
AdminAdd bool
|
AdminAdd bool
|
||||||
AdminAddPlaylists bool
|
AdminAddPlaylists bool
|
||||||
AdminSkip bool
|
AdminSkip bool
|
||||||
AdminHelp bool
|
AdminHelp bool
|
||||||
AdminVolume bool
|
AdminVolume bool
|
||||||
AdminMove bool
|
AdminMove bool
|
||||||
AdminReload bool
|
AdminReload bool
|
||||||
AdminReset bool
|
AdminReset bool
|
||||||
AdminNumSongs bool
|
AdminNumSongs bool
|
||||||
AdminNextSong bool
|
AdminNextSong bool
|
||||||
AdminCurrentSong bool
|
AdminCurrentSong bool
|
||||||
AdminSetComment bool
|
AdminSetComment bool
|
||||||
AdminNumCached bool
|
AdminNumCached bool
|
||||||
AdminCacheSize bool
|
AdminCacheSize bool
|
||||||
AdminKill bool
|
AdminKill bool
|
||||||
AdminShuffle bool
|
AdminShuffle bool
|
||||||
AdminShuffleToggle bool
|
AdminShuffleToggle bool
|
||||||
|
AdminListSongs bool
|
||||||
}
|
}
|
||||||
ServiceKeys struct {
|
ServiceKeys struct {
|
||||||
Youtube string
|
Youtube string
|
||||||
SoundCloud string
|
SoundCloud string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@ const HELP_HTML = `<br/>
|
||||||
<p><b>!skip</b> - Casts a vote to skip the current song</p>
|
<p><b>!skip</b> - Casts a vote to skip the current song</p>
|
||||||
<p> <b>!skipplaylist</b> - Casts a vote to skip over the current playlist.</p>
|
<p> <b>!skipplaylist</b> - Casts a vote to skip over the current playlist.</p>
|
||||||
<p><b>!numsongs</b> - Shows how many songs are in queue.</p>
|
<p><b>!numsongs</b> - Shows how many songs are in queue.</p>
|
||||||
|
<p><b>!listsongs</b> - Lists the songs in queue.</p>
|
||||||
<p><b>!nextsong</b> - Shows the title and submitter of the next queue item if it exists.</p>
|
<p><b>!nextsong</b> - Shows the title and submitter of the next queue item if it exists.</p>
|
||||||
<p><b>!currentsong</b> - Shows the title and submitter of the song currently playing.</p>
|
<p><b>!currentsong</b> - Shows the title and submitter of the song currently playing.</p>
|
||||||
<p style="-qt-paragraph-type:empty"><br/></p>
|
<p style="-qt-paragraph-type:empty"><br/></p>
|
||||||
|
@ -191,3 +192,6 @@ const CURRENT_SONG_HTML = `
|
||||||
const CURRENT_SONG_PLAYLIST_HTML = `
|
const CURRENT_SONG_PLAYLIST_HTML = `
|
||||||
The %s currently playing is "%s", added <b>%s</b> from the %s "%s".
|
The %s currently playing is "%s", added <b>%s</b> from the %s "%s".
|
||||||
`
|
`
|
||||||
|
const SONG_LIST_HTML = `
|
||||||
|
<br>"%s", added by <b>%s</b<.</br>
|
||||||
|
`
|
||||||
|
|
Reference in a new issue