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)
|
def pauseMusic_getName()
|
||||||
bot.message(start_with: "#{bang}Play ") do |event|
|
return "pause"
|
||||||
playMusic(bot, event, bang)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.message(with_text: "#{bang}Play") do |event|
|
def pauseMusic_getCommand()
|
||||||
event.respond "Please provide youtube link!"
|
return "pauseMusic_main"
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def playMusic_defined()
|
|
||||||
puts "This should not run"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def playMusic(bot, event, bang)
|
def pauseMusic_main(event)
|
||||||
message = event.content
|
|
||||||
author = event.author
|
|
||||||
voice_channel = event.author.voice_channel.id
|
voice_channel = event.author.voice_channel.id
|
||||||
server = event.server
|
if ENV["#{voice_channel}"] == 'playing'
|
||||||
arguments = message.sub("#{bang}Play ", '').split.first
|
event.respond "Pausing currently playing song"
|
||||||
#event.voice.play_file('./example.mp3')
|
voiceBot = $voicebots[voice_channel]
|
||||||
if arguments.include? "&list"
|
voiceBot.pause()
|
||||||
event.respond "Do not play playlists. They are unsupported."
|
ENV["#{voice_channel}"] = 'paused'
|
||||||
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
|
|
||||||
else
|
else
|
||||||
bot.voice_destroy(server)
|
event.respond "Bot not playing!"
|
||||||
event.respond "Done playing!"
|
|
||||||
ENV["#{voice_channel}"] = 'open'
|
|
||||||
end
|
end
|
||||||
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