This commit is contained in:
Matthieu Grieger 2015-02-07 14:23:47 -08:00
parent a28450e5ca
commit 0bb039b52f
6 changed files with 29 additions and 0 deletions

View file

@ -6,6 +6,7 @@ MumbleDJ Changelog
* Removed `sanitize` dependency.
* Reworked `Makefile` slightly.
* Now uses `gumbleutil.PlainText` for removing HTML tags instead of `sanitize`.
* Added `!setcomment` which allows admin users to set the comment for the bot.
### February 3, 2015 -- `v2.4.1`
* Made it possible to place MumbleDJ binary in `~/bin` instead of `/usr/local/bin` if the folder exists.

View file

@ -24,6 +24,7 @@ Command | Description | Arguments | Admin | Example
**numsongs** | Outputs the number of songs in the queue in chat. Individual songs and songs within playlists are both counted. | None | No | `!numsongs`
**nextsong** | Outputs the title and name of the submitter of the next song in the queue if it exists. | None | No | `!nextsong`
**currentsong** | Outputs the title and name of the submitter of the song currently playing. | None | No | `!currentsong`
**setcomment** | Sets the comment for the bot. If no argument is given, the current comment will be removed. | None OR new_comment | Yes | `!setcomment Hello! I am a bot. Type !help for the available commands.`
**kill** | Safely cleans the bot environment and disconnects from the server. Please use this command to stop the bot instead of force closing, as the kill command deletes any remaining songs in the `~/.mumbledj/songs` directory. | None | Yes | `!kill`

View file

@ -123,6 +123,13 @@ func parseCommand(user *gumble.User, username, command string) {
} else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
}
// Setcomment command
case dj.conf.Aliases.SetCommentAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminSetComment) {
setComment(user, argument)
} else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
}
// Kill command
case dj.conf.Aliases.KillAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminKill) {
@ -360,6 +367,12 @@ func currentSong(user *gumble.User) {
}
}
// Performs setcomment functionality. Sets the bot's comment to whatever text is supplied in the argument.
func setComment(user *gumble.User, comment string) {
dj.client.Self().SetComment(comment)
dj.SendPrivateMessage(user, COMMENT_UPDATED_MSG)
}
// Performs kill functionality. First cleans the ~/.mumbledj/songs directory to get rid of any
// excess m4a files. The bot then safely disconnects from the server.
func kill() {

View file

@ -83,6 +83,10 @@ NextSongAlias = "nextsong"
# DEFAULT VALUE: "currentsong"
CurrentSongAlias = "currentsong"
# Alias used for the setcomment command
# DEFAULT VALUE: "setcomment"
SetCommentAlias = "setcomment"
# Alias used for kill command
# DEFAULT VALUE: "kill"
KillAlias = "kill"
@ -147,6 +151,10 @@ AdminNextSong = false
# DEFAULT VALUE: false
AdminCurrentSong = false
# Make setcomment an admin command?
# DEFAULT VALUE: true
AdminSetComment = true
# Make kill an admin command?
# DEFAULT VALUE: true (I recommend never changing this to false)
AdminKill = true

View file

@ -39,6 +39,7 @@ type DjConfig struct {
NumSongsAlias string
NextSongAlias string
CurrentSongAlias string
SetCommentAlias string
KillAlias string
}
Permissions struct {
@ -55,6 +56,7 @@ type DjConfig struct {
AdminNumSongs bool
AdminNextSong bool
AdminCurrentSong bool
AdminSetComment bool
AdminKill bool
}
}

View file

@ -53,6 +53,9 @@ const AUDIO_FAIL_MSG = "The audio download for this video failed. YouTube has li
// Message shown to users when they supply a YouTube URL that does not contain a valid ID.
const INVALID_YOUTUBE_ID_MSG = "The YouTube URL you supplied did not contain a valid YouTube ID."
// Message shown to user when they successfully update the bot's comment.
const COMMENT_UPDATED_MSG = "The comment for the bot has successfully been updated."
// Message shown to a channel when a new song starts playing.
const NOW_PLAYING_HTML = `
<table>
@ -106,6 +109,7 @@ const HELP_HTML = `<br/>
<p><b>!forceskipplaylist</b> - An admin command that forces a playlist skip. </p>
<p><b>!move </b>- Moves MumbleDJ into channel if it exists.</p>
<p><b>!reload</b> - Reloads mumbledj.gcfg configuration settings.</p>
<p><b>!setcomment</b> - Sets the comment for the bot.</p>
<p><b>!kill</b> - Safely cleans the bot environment and disconnects from the server.</p>
`