Removed kill command, added mute and unmute

This commit is contained in:
Matthieu Grieger 2014-11-19 23:37:12 -08:00
parent 5d22afa2c6
commit abb1176160
3 changed files with 29 additions and 15 deletions

View file

@ -13,7 +13,7 @@ BOT_USERNAME = "MumbleDJTest"
# Password to join Mumble server # Password to join Mumble server
# DEFAULT VALUE: "" (leave it as this value if no password is required) # DEFAULT VALUE: "" (leave it as this value if no password is required)
MUMBLE_PASSWORD = "" MUMBLE_PASSWORD = ENV['MUMBLE_PW']
# Server address # Server address
# DEFAULT VALUE: "localhost" # DEFAULT VALUE: "localhost"
@ -77,9 +77,13 @@ VOLUME_ALIAS = "volume"
# DEFAULT VALUE: "move" # DEFAULT VALUE: "move"
MOVE_ALIAS = "move" MOVE_ALIAS = "move"
# Alias used for kill command # Alias used for mute command
# DEFAULT VALUE: "kill" # DEFAULT VALUE: "mute"
KILL_ALIAS = "kill" MUTE_ALIAS = "mute"
# Alias used for unmute command
# DEFAULT VALUE: "unmute"
UNMUTE_ALIAS = "unmute"
# ------------------- # -------------------
@ -112,8 +116,12 @@ ADMIN_VOLUME = true
# DEFAULT VALUE: true # DEFAULT VALUE: true
ADMIN_MOVE = true ADMIN_MOVE = true
# Make kill an admin command? # Make mute an admin command?
# DEFAULT VALUE: true (I recommend never changing this to false) # DEFAULT VALUE: true
ADMIN_KILL = true ADMIN_MUTE = true
# Make unmute an admin command?
# DEFAULT VALUE: true
ADMIN_UNMUTE = true

View file

@ -16,6 +16,7 @@ class MumbleDJ
# default_channel: The channel you would like the bot to connect to by # 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 # default. If the channel does not exist, the bot will connect to
# the root channel of the server instead. # 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) def initialize(username, server_address, server_port, default_channel, password)
@username = username @username = username
@password = password @password = password
@ -77,7 +78,7 @@ class MumbleDJ
puts("#{@sender} has added a song to the queue.") puts("#{@sender} has added a song to the queue.")
end end
if song_add_successful?(@argument, @sender) 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, "<b>#{@sender}</b> has added a song to the queue.")
else else
@client.text_user(@sender, "The URL you provided was not valid.") @client.text_user(@sender, "The URL you provided was not valid.")
end end
@ -105,10 +106,15 @@ class MumbleDJ
else else
@client.text_user(@sender, NO_PERMISSION_MSG) @client.text_user(@sender, NO_PERMISSION_MSG)
end end
# This one doesn't work for some reason. Gotta do some testing. when MUTE_ALIAS
when KILL_ALIAS if has_permission?(ADMIN_MUTE, @sender)
if has_permission?(ADMIN_KILL, @sender) @client.me.mute
disconnect else
@client.text_user(@sender, NO_PERMISSION_MSG)
end
when UNMUTE_ALIAS
if has_permission?(ADMIN_UNMUTE, @sender)
@client.me.mute(false)
else else
@client.text_user(@sender, NO_PERMISSION_MSG) @client.text_user(@sender, NO_PERMISSION_MSG)
end end

View file

@ -4,11 +4,11 @@
require_relative "mumbledj" require_relative "mumbledj"
require_relative "config" require_relative "config"
require 'thread' require "thread"
bot = MumbleDJ.new(username=BOT_USERNAME, server_address=MUMBLE_SERVER_ADDRESS, port=MUMBLE_SERVER_PORT, bot = MumbleDJ.new(username=BOT_USERNAME, server_address=MUMBLE_SERVER_ADDRESS, port=MUMBLE_SERVER_PORT,
default_channel=DEFAULT_CHANNEL, password=MUMBLE_PASSWORD) default_channel=DEFAULT_CHANNEL, password=MUMBLE_PASSWORD)
bot.connect bot.connect()
begin begin
t = Thread.new do t = Thread.new do