diff --git a/source/servers/sv_discord.rb b/source/servers/sv_discord.rb index 845e0e5..d2d6cc6 100644 --- a/source/servers/sv_discord.rb +++ b/source/servers/sv_discord.rb @@ -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