Add voice_play_io and voice_play to Sv_Discord
parent
71ad2dddd3
commit
9c1c320bf3
|
@ -32,32 +32,32 @@ class Sv_Discord < Vrobot4::Server::AudioServer
|
||||||
end
|
end
|
||||||
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)
|
# (see Vrobot4::Server::AudioServer#voice_join)
|
||||||
def voice_quit m
|
def voice_quit m
|
||||||
@bot.voice_destroy m.chan.real.server.id
|
@bot.voice_destroy m.chan.real.server.id
|
||||||
end
|
end
|
||||||
|
|
||||||
# (see Vrobot4::Server::AudioServer#voice_play)
|
# (see Vrobot4::Server::AudioServer#voice_play)
|
||||||
def voice_play m, io
|
def voice_play m, fname
|
||||||
v = @bot.voice(m.chan.real)
|
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 ArgumentError, "Invalid i/o stream" unless io
|
||||||
raise RuntimeError, "I'm not in a voice channel" unless v
|
raise RuntimeError, "I'm not in a voice channel" unless vc
|
||||||
v.play_stream io
|
Thread.new {vc.play_io io}
|
||||||
|
# HACK
|
||||||
|
sleep 1
|
||||||
|
oldst = nil
|
||||||
|
while vc.stream_time != oldst
|
||||||
|
oldst = vc.stream_time
|
||||||
|
sleep 5
|
||||||
|
end
|
||||||
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)
|
# (see Vrobot4::Server::Server#connect)
|
||||||
def connect
|
def connect
|
||||||
@bot.run
|
@bot.run
|
||||||
|
|
Loading…
Reference in New Issue