diff --git a/README.md b/README.md
index 34ef972..e8e7421 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@ Command | Description | Arguments | Admin | Example
**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`
**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`
**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`
diff --git a/commands.go b/commands.go
index 544569d..8de84b1 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) {
}
}
+// 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.
func reload(user *gumble.User) {
if err := loadConfiguration(); err == nil {
diff --git a/config.gcfg b/config.gcfg
index c210feb..ae6cb50 100644
--- a/config.gcfg
+++ b/config.gcfg
@@ -106,6 +106,10 @@ HelpAlias = "help"
# DEFAULT VALUE: "volume"
VolumeAlias = "volume"
+# Alias used for joinme
+# 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?
+# DEFAULT VALUE: true
+AdminJoinMe = true
+
# Make reload an admin command?
# DEFAULT VALUE: true
AdminReload = true
diff --git a/parseconfig.go b/parseconfig.go
index 7309add..d6f353e 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..5099637 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 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.
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 - Moves MumbleDJ into your current channel if not playing audio to someone else.
!reload - Reloads mumbledj.gcfg configuration settings.
!setcomment - Sets the comment for the bot.
!numcached
- Outputs the number of songs cached on disk.