Updates to the music modules, plus a few currently unfinished ones. Check modules.txt for both the ones loaded by default, and the ones which are safe.
parent
bea9003ea8
commit
c9a496d478
@ -0,0 +1,28 @@
|
||||
def listQueue_getCommand()
|
||||
return ["list", "listQueue_main"]
|
||||
end
|
||||
|
||||
def listQueue_main(event)
|
||||
voice_channel = event.author.voice_channel.id
|
||||
if ENV["#{voice_channel}"] == 'playing'
|
||||
if $queue.key?(voice_channel)
|
||||
if $queue[voice_channel][0] != nil
|
||||
x = $queue[voice_channel].length()
|
||||
y = 0
|
||||
qlist = ''
|
||||
while x >= 1
|
||||
qlist = qlist + "#{$queue[voice_channel][y].lstrip}\n"
|
||||
y = y + 1
|
||||
x= x - 1
|
||||
end
|
||||
event.respond "Current queue is:\n" + qlist
|
||||
else
|
||||
event.respond "No queue!"
|
||||
end
|
||||
else
|
||||
event.respond "No queue!"
|
||||
end
|
||||
else
|
||||
event.respond "Bot not playing!"
|
||||
end
|
||||
end
|
@ -1,66 +1,19 @@
|
||||
def playMusic_initialize(bot, bang)
|
||||
bot.message(start_with: "#{bang}Play ") do |event|
|
||||
playMusic(bot, event, bang)
|
||||
end
|
||||
|
||||
bot.message(with_text: "#{bang}Play") do |event|
|
||||
event.respond "Please provide youtube link!"
|
||||
end
|
||||
def pauseMusic_getName()
|
||||
return "pause"
|
||||
end
|
||||
|
||||
def playMusic_defined()
|
||||
puts "This should not run"
|
||||
def pauseMusic_getCommand()
|
||||
return "pauseMusic_main"
|
||||
end
|
||||
|
||||
def playMusic(bot, event, bang)
|
||||
message = event.content
|
||||
author = event.author
|
||||
def pauseMusic_main(event)
|
||||
voice_channel = event.author.voice_channel.id
|
||||
server = event.server
|
||||
arguments = message.sub("#{bang}Play ", '').split.first
|
||||
#event.voice.play_file('./example.mp3')
|
||||
if arguments.include? "&list"
|
||||
event.respond "Do not play playlists. They are unsupported."
|
||||
elsif ENV["#{voice_channel}"] == 'playing'
|
||||
event.respond "Music currently playing. Adding to queue"
|
||||
if $queue.key?(voice_channel) == false
|
||||
$queue[voice_channel] = Array.new
|
||||
$queue[voice_channel].push arguments
|
||||
puts $queue[voice_channel]
|
||||
else
|
||||
$queue[voice_channel].push arguments
|
||||
puts $queue[voice_channel]
|
||||
end
|
||||
elsif arguments.include? "youtu"
|
||||
actuallyPlayMusic(bot, event, arguments, voice_channel, server)
|
||||
else
|
||||
event.respond "Invalid youtube link!"
|
||||
end
|
||||
end
|
||||
|
||||
def actuallyPlayMusic(bot, event, arguments, voice_channel, server)
|
||||
event.respond "Playing song! This may take some time."
|
||||
bot.voice_connect(voice_channel)
|
||||
ENV["#{voice_channel}"] = 'playing'
|
||||
tempFile = Dir::Tmpname.create(['youtubedlruby-', '.mp3']) {}
|
||||
cmd = "yt-dlp --extract-audio --audio-format mp3 --output " + tempFile + " " + arguments
|
||||
if arguments.include? "youtu"
|
||||
system(cmd)
|
||||
end
|
||||
event.voice.play_file(tempFile)
|
||||
File.delete(tempFile) if File.exist?(tempFile)
|
||||
if $queue.key?(voice_channel) == true
|
||||
if $queue[voice_channel][0] != nil
|
||||
event.respond "Queue exists. Playing next song."
|
||||
actuallyPlayMusic(bot, event, $queue[voice_channel].shift, voice_channel, server)
|
||||
else
|
||||
bot.voice_destroy(server)
|
||||
event.respond "Done playing!"
|
||||
ENV["#{voice_channel}"] = 'open'
|
||||
end
|
||||
if ENV["#{voice_channel}"] == 'playing'
|
||||
event.respond "Pausing currently playing song"
|
||||
voiceBot = $voicebots[voice_channel]
|
||||
voiceBot.pause()
|
||||
ENV["#{voice_channel}"] = 'paused'
|
||||
else
|
||||
bot.voice_destroy(server)
|
||||
event.respond "Done playing!"
|
||||
ENV["#{voice_channel}"] = 'open'
|
||||
event.respond "Bot not playing!"
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
def unpauseMusic_getName()
|
||||
return "unpause"
|
||||
end
|
||||
|
||||
def unpauseMusic_getCommand()
|
||||
return "unpauseMusic_main"
|
||||
end
|
||||
|
||||
def unpauseMusic_main(event)
|
||||
voice_channel = event.author.voice_channel.id
|
||||
if ENV["#{voice_channel}"] == 'paused'
|
||||
event.respond "Unpausing currently playing song"
|
||||
voiceBot = $voicebots[voice_channel]
|
||||
voiceBot.continue()
|
||||
ENV["#{voice_channel}"] = 'playing'
|
||||
else
|
||||
event.respond "Bot not paused!"
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
def volumeMusic_getCommand()
|
||||
return ["volume", "volumeMusic_main"]
|
||||
end
|
||||
|
||||
def volumeMusic_main(event)
|
||||
message = event.content
|
||||
arguments = message.sub(/(!volume)/i, '').chomp
|
||||
if arguments == ''
|
||||
event.respond "Please add a volume from 1-200"
|
||||
else
|
||||
voice_channel = event.author.voice_channel.id
|
||||
if ENV["#{voice_channel}"] == 'playing'
|
||||
volVal = arguments.split.first.to_f
|
||||
voiceBot = $voicebots[voice_channel]
|
||||
volVal = volVal / 100
|
||||
puts volVal
|
||||
voiceBot.volume = volVal
|
||||
volVal = volVal * 100
|
||||
str = "Setting currently playing volume to " + volVal.to_s
|
||||
event.respond str
|
||||
else
|
||||
event.respond "Bot not playing!"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue