diff --git a/commands.go b/commands.go index 544569d..19bd96f 100644 --- a/commands.go +++ b/commands.go @@ -97,6 +97,13 @@ func parseCommand(user *gumble.User, username, command string) { } else { 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 case dj.conf.Aliases.ReloadAlias: if dj.HasPermission(username, dj.conf.Permissions.AdminReload) { @@ -347,6 +354,16 @@ func move(user *gumble.User, channel string) { } } +// move performance !joinme functionality. Found the channel and move the bot. The bot don't move +// if it already play music to people +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. func reload(user *gumble.User) { if err := loadConfiguration(); err == nil { diff --git a/config.gcfg b/config.gcfg index c210feb..527d07a 100644 --- a/config.gcfg +++ b/config.gcfg @@ -106,6 +106,10 @@ HelpAlias = "help" # DEFAULT VALUE: "volume" VolumeAlias = "volume" + Alias used for join a user +# DEFAULT VALUE : "joinme" +JoinMeAlias = "joinme" + # Alias used for move command # DEFAULT VALUE: "move" MoveAlias = "move" @@ -209,6 +213,10 @@ AdminVolume = false # DEFAULT VALUE: true AdminMove = true +# Make joinme a admin command? +# DEFUALT VALUE: true +AdminJoinMe = false + # Make reload an admin command? # DEFAULT VALUE: true AdminReload = true diff --git a/parseconfig.go b/parseconfig.go index 7309add..bda56e7 100644 --- a/parseconfig.go +++ b/parseconfig.go @@ -47,6 +47,7 @@ type DjConfig struct { HelpAlias string VolumeAlias string MoveAlias string + JoinMeAlias string ReloadAlias string ResetAlias string NumSongsAlias string @@ -72,6 +73,7 @@ type DjConfig struct { AdminHelp bool AdminVolume bool AdminMove bool + AdminJoinMe bool AdminReload bool AdminReset bool AdminNumSongs bool diff --git a/strings.go b/strings.go index 17e50dd..754139d 100644 --- a/strings.go +++ b/strings.go @@ -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 const SHUFFLE_DEACTIVATED_ERROR_MESSAGE = "Automatic shuffle is already deactivated." +// Message show to user when they attempt to move it and it is already playing music to people +const PEOPLE_ARE_LISTENING_TO_ME = "I'm already busy." + // Message shown to channel when a song is added to the queue by a user. const SONG_ADDED_HTML = ` %s has added "%s" to the queue. @@ -151,6 +154,7 @@ const HELP_HTML = `

!shuffleon - An admin command that enables auto shuffling.

!shuffleoff - An admin command that disables auto shuffling.

!move - Moves MumbleDJ into channel if it exists.

+

!joinme - Move into your channel (MP)

!reload - Reloads mumbledj.gcfg configuration settings.

!setcomment - Sets the comment for the bot.

!numcached

- Outputs the number of songs cached on disk.