mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Make PyNaCl optional
This commit is contained in:
parent
197e52994e
commit
e1f8bdc440
@ -154,6 +154,10 @@ class Client:
|
|||||||
self._is_logged_in = asyncio.Event(loop=self.loop)
|
self._is_logged_in = asyncio.Event(loop=self.loop)
|
||||||
self._is_ready = asyncio.Event(loop=self.loop)
|
self._is_ready = asyncio.Event(loop=self.loop)
|
||||||
|
|
||||||
|
if VoiceClient.warn_nacl:
|
||||||
|
VoiceClient.warn_nacl = False
|
||||||
|
log.warning("PyNaCl is not installed, voice will NOT be supported")
|
||||||
|
|
||||||
# internals
|
# internals
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -51,10 +51,15 @@ import shlex
|
|||||||
import functools
|
import functools
|
||||||
import datetime
|
import datetime
|
||||||
import audioop
|
import audioop
|
||||||
import nacl.secret
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import nacl.secret
|
||||||
|
has_nacl = True
|
||||||
|
except ImportError:
|
||||||
|
has_nacl = False
|
||||||
|
|
||||||
from . import utils, opus
|
from . import utils, opus
|
||||||
from .gateway import *
|
from .gateway import *
|
||||||
from .errors import ClientException, InvalidArgument, ConnectionClosed
|
from .errors import ClientException, InvalidArgument, ConnectionClosed
|
||||||
@ -182,6 +187,9 @@ class VoiceClient:
|
|||||||
The event loop that the voice client is running on.
|
The event loop that the voice client is running on.
|
||||||
"""
|
"""
|
||||||
def __init__(self, user, main_ws, session_id, channel, data, loop):
|
def __init__(self, user, main_ws, session_id, channel, data, loop):
|
||||||
|
if not has_nacl:
|
||||||
|
raise RuntimeError("PyNaCl library needed in order to use voice")
|
||||||
|
|
||||||
self.user = user
|
self.user = user
|
||||||
self.main_ws = main_ws
|
self.main_ws = main_ws
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
@ -196,6 +204,8 @@ class VoiceClient:
|
|||||||
self.encoder = opus.Encoder(48000, 2)
|
self.encoder = opus.Encoder(48000, 2)
|
||||||
log.info('created opus encoder with {0.__dict__}'.format(self.encoder))
|
log.info('created opus encoder with {0.__dict__}'.format(self.encoder))
|
||||||
|
|
||||||
|
warn_nacl = not has_nacl
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server(self):
|
def server(self):
|
||||||
return self.channel.server
|
return self.channel.server
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
aiohttp>=0.21.0,<0.22.0
|
aiohttp>=0.21.0,<0.22.0
|
||||||
websockets==3.1
|
websockets==3.1
|
||||||
PyNaCl==1.0.1
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user