Added version command both commandline and in chat
Hi! I've added a command line version argument, as well as a version command that the bot will respond to in chat. The current version is listed in the strings.go file.
This commit is contained in:
parent
e9093c1307
commit
e888271bc5
14
commands.go
14
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
7
main.go
7
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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <b>" + VERSION + "</b>."
|
||||
|
||||
// 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 = `<br/>
|
|||
<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>!currentsong</b> - Shows the title and submitter of the song currently playing.</p>
|
||||
<p><b>!version</b> - Shows the version of the bot.</p>
|
||||
<p style="-qt-paragraph-type:empty"><br/></p>
|
||||
<p><b>Admin Commands:</b></p>
|
||||
<p><b>!addnext</b> - Adds songs/playlists to queue after the current song.</p>
|
||||
|
|
Reference in a new issue