Commit Graph

107 Commits

Author SHA1 Message Date
ea2d972666 Make global log variable in modules private 2021-08-22 02:33:51 -04:00
f40f80c0dc Fix typo in voice_client.py 2021-07-04 19:14:07 -04:00
3c5c5fc274 Update documentation in voice_client.py 2021-06-28 03:10:33 -04:00
5acea453cc Type-hint voice_client / player 2021-06-28 00:59:14 -04:00
757cfad38f Type up **kwargs of various methods 2021-05-10 20:24:48 -04:00
3864fb37a0 Fix various reference issues in documentation
Co-Authored-By: Riley Shaw <30989490+ShineyDev@users.noreply.github.com>
2021-05-06 07:51:07 -04:00
8d74fad474 Update lavalink's repo url 2021-04-18 23:12:05 -04:00
89456022cf Add __all__ to remaining modules 2021-04-07 02:30:32 -04:00
9d39b135f4 Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
2021-04-04 07:03:53 -04:00
69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
52865dfa99 Clear the connected flag when potentially reconnecting the player
Fix #5953
2020-11-21 22:53:04 -05:00
b76b5b42c0 Fix attribute error during rapid disconnects in VoiceClient.
Fix #6039
2020-11-21 22:47:04 -05:00
21ed9f61d2 Fix disconnect when trying to move to another voice channel.
Not overly proud of this implementation but this allows the library
to differentiate between a 4014 that means "move to another channel" or
"move nowhere". Sometimes the VOICE_STATE_UPDATE comes before the
actual websocket disconnect so special care had to be taken in that
case.

Fix #5904
2020-10-17 22:01:57 -04:00
9036b9651b Properly handle disconnects in voice when force disconnected 2020-09-23 03:20:35 -04:00
9830e0ed8a Fix issues with VoiceProtocol docstrsings. 2020-09-23 03:20:35 -04:00
e3922e24d9 Correct some protocol errors in v4 of voice gateway 2020-09-23 03:20:35 -04:00
0b93fa3a82 Implement VoiceProtocol lower level hooks.
This allows changing the connect flow and taking control of it without
relying on internal events or tricks.
2020-09-23 03:20:35 -04:00
250f29989b Be defensive in case Discord breaks something with WS URLs again 2020-08-05 08:35:43 -04:00
a9824ffabf Fix endpoint strings with :443 instead of :80
Fix #5191
Close #5188
2020-08-05 04:21:27 -04:00
5cbbbca193 Add versionadded to VoiceClient latency and average_latency 2020-06-26 22:57:32 -04:00
4078d64520 Fix reconnecting loop due to failed handshake on region change 2020-06-22 04:00:40 -04:00
ddfed5a610 Change _handshaking variable when handshake terminate 2020-05-23 21:56:40 -04:00
Fwf
fa34d357a1 Added VoiceClient.latency and VoiceClient.average_latency
This also implements the heartbeating a bit more consistent to the
official Discord client.
2020-04-04 03:00:27 -04:00
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
bcbfc354cf Add support for xsalsa20_poly1305_lite 2019-12-17 00:11:40 -05:00
839afce178 Print exception tracebacks in voice threads
Errors occurring within `AudioSource.read()` and `after()` functions will now display their tracebacks as if they were unhandled exceptions.
2019-11-26 05:16:53 -05:00
a6f61dcbde Fix all deprecation warnings for 3.8 2019-11-20 02:30:19 -05:00
fedf26bf3e Add FFmpegOpusAudio and other voice improvements
Rework FFmpeg player and add FFmpegOpusAudio

I have extracted some of the base FFmpeg source code into its own
base class and reimplemented the PCM and the new Opus variants.

Support avconv probing

Also fix a few things

Update `__all__`

Fix the bugs

Rework probe functions and add factory function

Probing involves subprocess so it has been reworked into an async
factory function.

Add docs + a few tweaks

* Removed unnecessary read() and is_opus() functions from FFmpegAudio
* Clear self._stdout in cleanup()
* Add 20 second process communication timeout to probe functions
* Capped probe function bitrate values at 512

Change AudioPlayer to use more accurate, monotonic time.perf_counter()

Add lazy opus loading

The library now no longer loads libopus on import, only on
opus.Encoder creation or manually.

Fix review nits
2019-07-22 20:46:40 -04:00
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
abb9c067cc Add log line to show if we disconnected normally. 2019-05-01 02:49:52 -04:00
7eb8417883 Fix voice handshake race condition
In the event that two voice_server_updates are received in a short time frame, the second one is now ignored.
2019-04-10 00:55:52 -04:00
3a36f78e08 Use is_connected() instead of _connected in checks
Was doing a falsy check on an Event object instead of using the (unused) is_connected() function.
2019-04-09 00:14:41 -04:00
78459f3ed0 Don't reconnect during 4014/4015 in voice websocket. 2019-03-05 19:45:13 -05:00
9c5259afd7 Update voice code to vws V4
- Update internals to be compatible with v4
- Adds multiple encryption mode support.  Previously only `xsalsa20_poly1305` was supported.  Now `xsalsa20_poly1305_suffix` is also supported.
  Note: There is no (nice) way to manually select a mode.  The user needn't worry about this however.
- Fixed speaking state bug.  When you disconnected from a voice channel while a bot was playing, upon reconnect you would be unable to hear the bot.  This was caused by bots not sending their speaking state while transmitting.  Bots will now set their speaking state properly when transmitting.  
  Note: This does not account for sending actual silence, the speaking indicator will still be active.
2019-01-28 22:22:52 -05:00
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
efb4ff850e [lint] Fix import order
Reorder imports to be consistenly grouped by standard library, third
party library, and local modules in that order thoughout the library.
2018-11-24 22:17:58 -05:00
fa46b07db1 [lint] Rename exception variables to exc
Use the more explicit (and common) exc instead of e as the variable
holding the exception in except handlers.
2018-11-24 22:17:57 -05:00
4ae8e81660 [lint] Remove redundant exception variables
Use bare raise statement when reraising the exception that occured, and
remove unused exception variables.  Also remove a pointless exception
handler in discord.opus.
2018-11-24 22:17:57 -05:00
a71b3b5fa0 [lint] Limit unneccessarily broad except clauses
Add exception qualifier(s) to bare except clauses swallowing exceptions.
2018-11-24 22:17:57 -05:00
5c24e69cf2 Fix up the Sphinx strings causing warnings. 2018-09-15 09:54:00 -04:00
119c5a0618 [lint] Remove unused variables
Left over from various refactoring and rewrites.
2018-08-22 21:43:51 -04:00
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