diff --git a/mumbledj/config.rb b/mumbledj/config.rb index 522dca1..650dfe8 100644 --- a/mumbledj/config.rb +++ b/mumbledj/config.rb @@ -13,7 +13,7 @@ BOT_USERNAME = "MumbleDJTest" # Password to join Mumble server # DEFAULT VALUE: "" (leave it as this value if no password is required) -MUMBLE_PASSWORD = "" +MUMBLE_PASSWORD = ENV['MUMBLE_PW'] # Server address # DEFAULT VALUE: "localhost" @@ -77,9 +77,13 @@ VOLUME_ALIAS = "volume" # DEFAULT VALUE: "move" MOVE_ALIAS = "move" -# Alias used for kill command -# DEFAULT VALUE: "kill" -KILL_ALIAS = "kill" +# Alias used for mute command +# DEFAULT VALUE: "mute" +MUTE_ALIAS = "mute" + +# Alias used for unmute command +# DEFAULT VALUE: "unmute" +UNMUTE_ALIAS = "unmute" # ------------------- @@ -112,8 +116,12 @@ ADMIN_VOLUME = true # DEFAULT VALUE: true ADMIN_MOVE = true -# Make kill an admin command? -# DEFAULT VALUE: true (I recommend never changing this to false) -ADMIN_KILL = true +# Make mute an admin command? +# DEFAULT VALUE: true +ADMIN_MUTE = true + +# Make unmute an admin command? +# DEFAULT VALUE: true +ADMIN_UNMUTE = true diff --git a/mumbledj/mumbledj.rb b/mumbledj/mumbledj.rb index ae201df..a04d0a8 100644 --- a/mumbledj/mumbledj.rb +++ b/mumbledj/mumbledj.rb @@ -16,6 +16,7 @@ class MumbleDJ # default_channel: The channel you would like the bot to connect to by # default. If the channel does not exist, the bot will connect to # the root channel of the server instead. + # password: Password to join a password-protected server def initialize(username, server_address, server_port, default_channel, password) @username = username @password = password @@ -77,7 +78,7 @@ class MumbleDJ puts("#{@sender} has added a song to the queue.") end if song_add_successful?(@argument, @sender) - @client.text_channel("#(@sender} has added a song to the queue.") + @client.text_channel(@client.me.current_channel.name, "#{@sender} has added a song to the queue.") else @client.text_user(@sender, "The URL you provided was not valid.") end @@ -105,10 +106,15 @@ class MumbleDJ else @client.text_user(@sender, NO_PERMISSION_MSG) end - # This one doesn't work for some reason. Gotta do some testing. - when KILL_ALIAS - if has_permission?(ADMIN_KILL, @sender) - disconnect + when MUTE_ALIAS + if has_permission?(ADMIN_MUTE, @sender) + @client.me.mute + else + @client.text_user(@sender, NO_PERMISSION_MSG) + end + when UNMUTE_ALIAS + if has_permission?(ADMIN_UNMUTE, @sender) + @client.me.mute(false) else @client.text_user(@sender, NO_PERMISSION_MSG) end diff --git a/mumbledj/run_bot.rb b/mumbledj/run_bot.rb index e02a0ad..34274b7 100644 --- a/mumbledj/run_bot.rb +++ b/mumbledj/run_bot.rb @@ -4,11 +4,11 @@ require_relative "mumbledj" require_relative "config" -require 'thread' +require "thread" bot = MumbleDJ.new(username=BOT_USERNAME, server_address=MUMBLE_SERVER_ADDRESS, port=MUMBLE_SERVER_PORT, - default_channel=DEFAULT_CHANNEL, password=MUMBLE_PASSWORD) -bot.connect + default_channel=DEFAULT_CHANNEL, password=MUMBLE_PASSWORD) +bot.connect() begin t = Thread.new do