!joinme feacture (#148)

!joinme feature implementation
This commit is contained in:
azlux 2016-06-17 19:43:11 +02:00 committed by Matthieu Grieger
parent e133c0efcb
commit 99c19cf8a8
5 changed files with 32 additions and 0 deletions

View file

@ -57,6 +57,7 @@ Command | Description | Arguments | Admin | Example
**help** | Displays this list of commands in Mumble chat. | None | No | `!help` **help** | Displays this list of commands in Mumble chat. | None | No | `!help`
**volume** | Either outputs the current volume or changes the current volume. If desired volume is not provided, the current volume will be displayed in chat. Otherwise, the volume for the bot will be changed to desired volume if it is within the allowed volume range. | None OR desired volume | No | `!volume 0.5`, `!volume` **volume** | Either outputs the current volume or changes the current volume. If desired volume is not provided, the current volume will be displayed in chat. Otherwise, the volume for the bot will be changed to desired volume if it is within the allowed volume range. | None OR desired volume | No | `!volume 0.5`, `!volume`
**move** | Moves MumbleDJ into channel if it exists. | Channel | Yes | `!move Music` **move** | Moves MumbleDJ into channel if it exists. | Channel | Yes | `!move Music`
**joinme** | Moves MumbleDJ into your current channel if not playing audio to someone else. | None | Yes | `!joinme`
**reload** | Reloads `mumbledj.gcfg` to retrieve updated configuration settings. | None | Yes | `!reload` **reload** | Reloads `mumbledj.gcfg` to retrieve updated configuration settings. | None | Yes | `!reload`
**reset** | Stops all audio and resets the song queue. | None | Yes | `!reset` **reset** | Stops all audio and resets the song queue. | None | Yes | `!reset`
**numsongs** | Outputs the number of songs in the queue in chat. Individual songs and songs within playlists are both counted. | None | No | `!numsongs` **numsongs** | Outputs the number of songs in the queue in chat. Individual songs and songs within playlists are both counted. | None | No | `!numsongs`

View file

@ -97,6 +97,13 @@ func parseCommand(user *gumble.User, username, command string) {
} else { } else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG) dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
} }
// JoinMe command
case dj.conf.Aliases.JoinMeAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminJoinMe) {
joinMe(user)
} else {
dj.SendPrivateMessage(user, NO_PERMISSION_MSG)
}
// Reload command // Reload command
case dj.conf.Aliases.ReloadAlias: case dj.conf.Aliases.ReloadAlias:
if dj.HasPermission(username, dj.conf.Permissions.AdminReload) { if dj.HasPermission(username, dj.conf.Permissions.AdminReload) {
@ -347,6 +354,16 @@ func move(user *gumble.User, channel string) {
} }
} }
// joinMe performs !joinme functionality. Finds the channel and moves the bot.
// The bot does not move if it is already playing audio to others.
func joinMe(user *gumble.User) {
if dj.audioStream.IsPlaying() && len(dj.client.Self.Channel.Users) > 1 {
user.Send(PEOPLE_ARE_LISTENING_TO_ME)
} else {
dj.client.Self.Move(user.Channel)
}
}
// reload performs !reload functionality. Tells command submitter if the reload completed successfully. // reload performs !reload functionality. Tells command submitter if the reload completed successfully.
func reload(user *gumble.User) { func reload(user *gumble.User) {
if err := loadConfiguration(); err == nil { if err := loadConfiguration(); err == nil {

View file

@ -106,6 +106,10 @@ HelpAlias = "help"
# DEFAULT VALUE: "volume" # DEFAULT VALUE: "volume"
VolumeAlias = "volume" VolumeAlias = "volume"
# Alias used for joinme
# DEFAULT VALUE : "joinme"
JoinMeAlias = "joinme"
# Alias used for move command # Alias used for move command
# DEFAULT VALUE: "move" # DEFAULT VALUE: "move"
MoveAlias = "move" MoveAlias = "move"
@ -209,6 +213,10 @@ AdminVolume = false
# DEFAULT VALUE: true # DEFAULT VALUE: true
AdminMove = true AdminMove = true
# Make joinme a admin command?
# DEFAULT VALUE: true
AdminJoinMe = true
# Make reload an admin command? # Make reload an admin command?
# DEFAULT VALUE: true # DEFAULT VALUE: true
AdminReload = true AdminReload = true

View file

@ -47,6 +47,7 @@ type DjConfig struct {
HelpAlias string HelpAlias string
VolumeAlias string VolumeAlias string
MoveAlias string MoveAlias string
JoinMeAlias string
ReloadAlias string ReloadAlias string
ResetAlias string ResetAlias string
NumSongsAlias string NumSongsAlias string
@ -72,6 +73,7 @@ type DjConfig struct {
AdminHelp bool AdminHelp bool
AdminVolume bool AdminVolume bool
AdminMove bool AdminMove bool
AdminJoinMe bool
AdminReload bool AdminReload bool
AdminReset bool AdminReset bool
AdminNumSongs bool AdminNumSongs bool

View file

@ -98,6 +98,9 @@ const SHUFFLE_ACTIVATED_ERROR_MESSAGE = "Automatic shuffle is already activated.
// Message shown to user when they attempt to disable automatic shuffle while it's already deactivated // Message shown to user when they attempt to disable automatic shuffle while it's already deactivated
const SHUFFLE_DEACTIVATED_ERROR_MESSAGE = "Automatic shuffle is already deactivated." const SHUFFLE_DEACTIVATED_ERROR_MESSAGE = "Automatic shuffle is already deactivated."
// Message shown to user when they attempt to move the bot and it is already playing audio to others.
const PEOPLE_ARE_LISTENING_TO_ME = "Users in another channel are listening to me."
// Message shown to channel when a song is added to the queue by a user. // Message shown to channel when a song is added to the queue by a user.
const SONG_ADDED_HTML = ` const SONG_ADDED_HTML = `
<b>%s</b> has added "%s" to the queue. <b>%s</b> has added "%s" to the queue.
@ -151,6 +154,7 @@ const HELP_HTML = `<br/>
<p><b>!shuffleon</b> - An admin command that enables auto shuffling.</p> <p><b>!shuffleon</b> - An admin command that enables auto shuffling.</p>
<p><b>!shuffleoff</b> - An admin command that disables auto shuffling.</p> <p><b>!shuffleoff</b> - An admin command that disables auto shuffling.</p>
<p><b>!move </b>- Moves MumbleDJ into channel if it exists.</p> <p><b>!move </b>- Moves MumbleDJ into channel if it exists.</p>
<p><b>!joinme </b>- Moves MumbleDJ into your current channel if not playing audio to someone else.</p>
<p><b>!reload</b> - Reloads mumbledj.gcfg configuration settings.</p> <p><b>!reload</b> - Reloads mumbledj.gcfg configuration settings.</p>
<p><b>!setcomment</b> - Sets the comment for the bot.</p> <p><b>!setcomment</b> - Sets the comment for the bot.</p>
<p><b>!numcached</b></p> - Outputs the number of songs cached on disk.</p> <p><b>!numcached</b></p> - Outputs the number of songs cached on disk.</p>