Commit Graph

66 Commits

Author SHA1 Message Date
f25091efe1 Drop support for Python 3.4 and make minimum version 3.5.2. 2018-06-10 18:10:00 -04:00
a425bd91be Fix invalid close errors on websockets 4.x
Fixes #1110
2018-03-06 00:15:36 -05:00
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
305cc3acfa Clarify VoiceClient.disconnect docs a little more. 2017-09-16 13:29:36 -04:00
fe3b917564 Continue connection loop with back-off if connecting fails >5 times. 2017-07-25 20:00:00 -04:00
b06899e7d4 Defer logging formatting until the logger is actually called.
This would cause unnecessary format calls even if you didn't have
logging enabled.
2017-06-09 18:53:24 -04:00
64d09f3720 Force disconnect in abc.Connectable.connect.
Some cases of is_connected is not set so we need to force it to clear
it anyway.
2017-05-13 16:01:32 -04:00
b44bba6ee6 First pass at documentation reform. 2017-05-12 20:14:34 -04:00
663315f7ac Explicitly close UDP sockets when re-creating them.
This does not actually make a big difference since the GC should
technically close them when needed but might as well be more explicit.
2017-05-02 20:25:54 -04:00
f5cfc96aaf Add PCMVolumeTransformer to augment volume of a PCM stream.
This also introduces the idea of replacing the VoiceClient.source on
the fly. Note that this internally pauses and resumes the audio
stream.
2017-04-19 17:23:39 -04:00
07d5328873 Add VoiceClient.is_paused to query pause state. 2017-04-19 16:06:45 -04:00
55e63ed87f Add VoiceClient.source to get the AudioSource being played. 2017-04-19 01:19:39 -04:00
aa32c384ea Clean cache when TimeoutError occurs. 2017-04-18 20:13:34 -04:00
f9c2ac9d25 Better handling of VOICE_SERVER_UPDATE.
This now sort of respects "Awaiting Endpoint..." waiting. I haven't
actually tested out this case since it's hard to get it. However this
new code does work with the regular connection flow.
2017-04-18 19:05:34 -04:00
3b1b26ffb1 Re-implement voice sending.
This is a complete redesign of the old voice code.

A list of major changes is as follows:

* The voice websocket will now automatically reconnect with
  exponential back-off just like the regular Client does.
* Removal of the stream player concept.
* Audio now gracefully pauses and resumes when a disconnect is found.
* Introduce a discord.AudioSource concept to abstract streams
* Flatten previous stream player functionality with the
  VoiceClient, e.g. player.stop() is now voice_client.stop()
* With the above re-coupling this means you no longer have to
  store players anywhere.
* The after function now requires a single parameter, the error,
  if any existed. This will typically be None.

A lot of this design is experimental.
2017-04-18 03:49:48 -04:00
132ac45010 Ensure after is called inside the daemon thread for players. 2017-02-14 02:10:07 -05:00
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00
79a49f9145 Absolute import some circular dependencies to appease Python 3.4. 2017-01-03 09:52:02 -05:00
d1d54a468a Rename Server to Guild everywhere. 2017-01-03 09:51:54 -05:00
6fec17d7d4 Catch Player errors and gracefully stop them.
This also introduces the concept of the after function taking a single
parameter, the current player. This is useful for error handling, e.g.
checking Player.error.

Fixes #291
2016-09-25 05:27:35 -04:00
e977bddc1f Add stderr arg to create_ffmpeg_player 2016-07-08 14:48:04 -04:00
e1f8bdc440 Make PyNaCl optional 2016-06-28 00:58:11 -04:00
102e8aca43 Raise TypeError if "after" parameter is not a callable. 2016-06-20 01:05:28 -04:00
e736554777 Make sure the socket is closed when we call VoiceClient.disconnect 2016-06-14 22:33:25 -04:00
fe5c369fe9 Handle voice websocket closure if it's a successful close. 2016-06-10 21:45:42 -04:00
41a2b5ed73 Actually read from the voice websocket & fix heartbeat.
This change makes it so that the buffer doesn't fill and the voice server drops the socket.

Also, use correct interval for voice websocket heartbeat.
2016-06-05 21:18:36 -07:00
13a9a7520c Fix ytdl documentation link. 2016-05-27 15:00:50 -04:00
1155a0aaa4 Make Player threads into daemon threads. 2016-05-12 06:06:38 -04:00
3c04ec2af0 Add a way to change the player volume. 2016-05-12 06:06:38 -04:00
339e26275f Add VoiceClient.move_to for quick switching of voice channels. 2016-05-12 06:06:37 -04:00
2fc496304c Add libopus DLLs for ease of use. 2016-05-06 12:23:24 -04:00
d9c780b8a8 Working multi-server voice support. 2016-05-01 20:54:13 -04:00
c1b5a52823 Refactor voice websocket into gateway.py 2016-04-27 18:36:24 -04:00
ee4574a5e1 Drop voice packets when it can be potentially blocking. 2016-03-31 23:44:22 -04:00
719c0269f4 Encrypted audio working with PyNacl
I chose PyNacl since it came with its own libsodium portable copy.
2016-03-31 23:03:34 -04:00
827ca1e5a2 Add boolean option to specify if VoiceClient.play_audio should encode.
This allows people to send raw opus encoded data instead of being
forced to encode to Opus.
2016-03-25 19:12:59 -04:00
4fa1bcadaa Add a way to set ffmpeg options before the -i flag. 2016-03-25 18:49:23 -04:00
f1736bc08f Move ffmpeg process cleanup to player thread 2016-03-25 18:32:02 -04:00
fc2127789a Support ytsearch and playlists in youtube_dl_player 2016-03-09 21:19:12 -05:00
b10432d393 Disconnect from voice server properly
This needs to exist when users get flagged as bots.
2016-03-04 18:47:50 -08:00
ef57873f80 Clean up zombies
self.process.communicate(timeout=0.100) will block

zombies probably would be cleaned up anyways but in a non deterministic fashion by the garage collector
2016-03-02 23:25:20 -05:00
1cd3c0b5cb Make VoiceClient.create_ytdl_player a coroutine.
This is a breaking change. The reason to make it a coroutine is so that
the info retrieval is not blocking since there are rare instances where
it would take an abnormally long time. The player returned is also
augmented to have more attributes relating to the stream itself.
2016-01-31 22:06:12 -05:00
b4604fa3f6 Change options in VoiceClient.create_ytdl_player to ytdl_options.
This is a breaking change. This allows you to set both ffmpeg options
and regular ytdl options in the same function since we now just
forward the keyword arguments to the ffmpeg player.
2016-01-31 17:49:40 -05:00
3d21a186fe Try to make the pause/resume loop not busy. 2016-01-26 22:27:19 -05:00
f075548d78 add `headers` option to create_ffmpeg_player()
headers can't be passed through 'options' because in '-headers' flag shoul be placed before '-i'
At least for ffmpeg 2.8.4
2016-01-26 22:27:00 -05:00
1f5d26b7d3 Unit correction in voice docstrings. 2016-01-18 17:44:16 -05:00
6c7a493fd9 Raise a different exception if ffmpeg is not found in PATH. 2016-01-16 21:46:11 -05:00
4edff12f6b Proper exception chaining. 2016-01-13 20:08:55 -05:00
c1347dfcf0 Remove excessive logging when using voice. 2016-01-06 12:19:59 -05:00
db4cc791dd Update license of files to 2016. 2016-01-04 22:28:29 -05:00