aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHornwitser <[email protected]>2016-06-28 00:57:52 -0400
committerRapptz <[email protected]>2016-06-28 00:58:11 -0400
commite1f8bdc440eaff0f2e04ffa017052117621fe939 (patch)
tree76372f422095f7011813b700e3a14eff27030cb1
parentUpdate whats new page a little bit to say the changelog is too big. (diff)
downloaddiscord.py-e1f8bdc440eaff0f2e04ffa017052117621fe939.tar.xz
discord.py-e1f8bdc440eaff0f2e04ffa017052117621fe939.zip
Make PyNaCl optional
-rw-r--r--discord/client.py4
-rw-r--r--discord/voice_client.py12
-rw-r--r--requirements.txt1
3 files changed, 15 insertions, 2 deletions
diff --git a/discord/client.py b/discord/client.py
index 5ab263cd..3a2ef8fb 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -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
diff --git a/discord/voice_client.py b/discord/voice_client.py
index c5b24a77..a92bf5b8 100644
--- a/discord/voice_client.py
+++ b/discord/voice_client.py
@@ -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
diff --git a/requirements.txt b/requirements.txt
index 9221d17a..f4c9a5d8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,2 @@
aiohttp>=0.21.0,<0.22.0
websockets==3.1
-PyNaCl==1.0.1