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_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
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -51,10 +51,15 @@ import shlex
|
||||
import functools
|
||||
import datetime
|
||||
import audioop
|
||||
import nacl.secret
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import nacl.secret
|
||||
has_nacl = True
|
||||
except ImportError:
|
||||
has_nacl = False
|
||||
|
||||
from . import utils, opus
|
||||
from .gateway import *
|
||||
from .errors import ClientException, InvalidArgument, ConnectionClosed
|
||||
@ -182,6 +187,9 @@ class VoiceClient:
|
||||
The event loop that the voice client is running on.
|
||||
"""
|
||||
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.main_ws = main_ws
|
||||
self.channel = channel
|
||||
@ -196,6 +204,8 @@ class VoiceClient:
|
||||
self.encoder = opus.Encoder(48000, 2)
|
||||
log.info('created opus encoder with {0.__dict__}'.format(self.encoder))
|
||||
|
||||
warn_nacl = not has_nacl
|
||||
|
||||
@property
|
||||
def server(self):
|
||||
return self.channel.server
|
||||
|
@ -1,3 +1,2 @@
|
||||
aiohttp>=0.21.0,<0.22.0
|
||||
websockets==3.1
|
||||
PyNaCl==1.0.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user