diff --git a/commands.go b/commands.go index 2e81c29..544569d 100644 --- a/commands.go +++ b/commands.go @@ -192,6 +192,14 @@ func parseCommand(user *gumble.User, username, command string) { } else { dj.SendPrivateMessage(user, NO_PERMISSION_MSG) } + + // Version command + case dj.conf.Aliases.VersionAlias: + if dj.HasPermission(username, dj.conf.Permissions.AdminVersion) { + version(user) + } else { + dj.SendPrivateMessage(user, NO_PERMISSION_MSG) + } default: dj.SendPrivateMessage(user, COMMAND_DOESNT_EXIST_MSG) } @@ -501,3 +509,9 @@ func listSongs(user *gumble.User, value string) { dj.SendPrivateMessage(user, NO_MUSIC_PLAYING_MSG) } } + +// version handles !version functionality. Sends a private message to the user with the most recent version of MumbleDJ +func version(user *gumble.User) { + dj.SendPrivateMessage(user, DJ_VERSION) +} + diff --git a/config.gcfg b/config.gcfg index 6998fa6..c210feb 100644 --- a/config.gcfg +++ b/config.gcfg @@ -162,6 +162,10 @@ ShuffleOffAlias = "shuffleoff" # DEFAULT_VALUE: "listsongs" ListSongsAlias = "listsongs" +# Alias used for version command +# DEFAULT_VALUE: "version" +VersionAlias = "version" + [Permissions] # Enable admins @@ -249,6 +253,10 @@ AdminShuffle = true # DEFAULT VALUE: false AdminListSongs = false +# Make version an admin command? +# DEFAULT VALUE: false +AdminVersion = false + # Make shuffleon and shuffleoff admin commands? # DEFAULT VALUE: true AdminShuffleToggle = true diff --git a/main.go b/main.go index a63f7a3..89bfd0c 100644 --- a/main.go +++ b/main.go @@ -199,6 +199,7 @@ func main() { var address, port, username, password, channel, pemCert, pemKey, accesstokens string var insecure bool + var version bool flag.StringVar(&address, "server", "localhost", "address for Mumble server") flag.StringVar(&port, "port", "64738", "port for Mumble server") @@ -209,8 +210,14 @@ func main() { flag.StringVar(&pemKey, "key", "", "path to user PEM key for MumbleDJ") flag.StringVar(&accesstokens, "accesstokens", "", "list of access tokens for channel auth") flag.BoolVar(&insecure, "insecure", false, "skip certificate checking") + flag.BoolVar(&version, "version", false, "show version") flag.Parse() + if version { + fmt.Printf("MumbleDJ version %s\n", VERSION) + os.Exit(0) + } + dj.config = gumble.Config{ Username: username, Password: password, diff --git a/parseconfig.go b/parseconfig.go index 591bef1..7309add 100644 --- a/parseconfig.go +++ b/parseconfig.go @@ -60,6 +60,7 @@ type DjConfig struct { ShuffleOnAlias string ShuffleOffAlias string ListSongsAlias string + VersionAlias string } Permissions struct { AdminsEnabled bool @@ -83,6 +84,7 @@ type DjConfig struct { AdminShuffle bool AdminShuffleToggle bool AdminListSongs bool + AdminVersion bool } ServiceKeys struct { Youtube string diff --git a/strings.go b/strings.go index 438caee..0a8f06b 100644 --- a/strings.go +++ b/strings.go @@ -7,6 +7,12 @@ package main +// Current version of the bot +const VERSION = "v2.8.12" + +// Message shown to users when they request the version of the bot +const DJ_VERSION = "I'm currently running version MumbleDJ " + VERSION + "." + // Message shown to users when the bot has an invalid API key. const INVALID_API_KEY = "MumbleDJ does not have a valid %s API key." @@ -131,6 +137,7 @@ const HELP_HTML = `

!listsongs - Lists the songs in queue.

!nextsong - Shows the title and submitter of the next queue item if it exists.

!currentsong - Shows the title and submitter of the song currently playing.

+

!version - Shows the version of the bot.


Admin Commands:

!addnext - Adds songs/playlists to queue after the current song.