Add voice_play_io and voice_play to Sv_Discord

master
Marrub 2017-09-11 07:00:43 -04:00
parent 71ad2dddd3
commit 9c1c320bf3
1 changed files with 18 additions and 18 deletions

View File

@ -32,32 +32,32 @@ class Sv_Discord < Vrobot4::Server::AudioServer
end
end
# (see Vrobot4::Server::AudioServer#voice_join)
def voice_join m
chan = m.user.real.voice_channel
raise RuntimeError, "You're not in a voice channel" unless chan
@bot.voice_connect chan
end
# (see Vrobot4::Server::AudioServer#voice_join)
def voice_quit m
@bot.voice_destroy m.chan.real.server.id
end
# (see Vrobot4::Server::AudioServer#voice_play)
def voice_play m, io
v = @bot.voice(m.chan.real)
def voice_play m, fname
vc = @bot.voice(m.chan.real)
raise RuntimeError, "I'm not in a voice channel" unless vc
vc.play_file fname
end
# (see Vrobot4::Server::AudioServer#voice_play_io)
def voice_play_io m, io
vc = @bot.voice(m.chan.real)
raise ArgumentError, "Invalid i/o stream" unless io
raise RuntimeError, "I'm not in a voice channel" unless v
v.play_stream io
raise RuntimeError, "I'm not in a voice channel" unless vc
Thread.new {vc.play_io io}
# HACK
sleep 1
oldst = nil
while vc.stream_time != oldst
oldst = vc.stream_time
sleep 5
end
end
# (see Vrobot4::Server::AudioServer#is_playing?)
def is_playing? m
v = @bot.voice(m.chan.real)
v != nil and v.playing?
end
# (see Vrobot4::Server::Server#connect)
def connect
@bot.run