Skip to content

Commit

Permalink
Merge branch 'features/voice-receive'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Jan 10, 2022
2 parents ef9b598 + 740c41e commit e58dd4d
Show file tree
Hide file tree
Showing 9 changed files with 912 additions and 168 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docs/crowdin.py
*.mp3
*.m4a
*.wav
*.pcm
*.png
*.jpg
*.flac
Expand All @@ -18,6 +19,8 @@ docs/crowdin.py
.DS_Store
.python-version
__pycache__
.vs/slnx.sqlite
.vs/*
.vscode/*
env/
build/
test.py
1 change: 1 addition & 0 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .sticker import *
from .stage_instance import *
from .interactions import *
from .sink import *
from .components import *
from .threads import *
from .bot import *
Expand Down
14 changes: 14 additions & 0 deletions discord/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
'NoEntryPointError',
'ExtensionFailed',
'ExtensionNotFound',
'RecordingException',
)


Expand Down Expand Up @@ -269,6 +270,19 @@ def __init__(self, shard_id: Optional[int]):
)
super().__init__(msg % shard_id)

class RecordingException(ClientException):
"""Exception that's thrown when there is an error while trying to record
audio from a voice channel.
.. versionadded:: 2.0
"""
pass

class SinkException(ClientException):
"""Raised when a Sink error occurs.
.. versionadded:: 2.0
"""

class InteractionResponded(ClientException):
"""Exception that's raised when sending another interaction response using
Expand Down
10 changes: 10 additions & 0 deletions discord/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ def __init__(self, socket, loop, *, hook=None):
self._keep_alive = None
self._close_code = None
self.secret_key = None
self.ssrc_map = {}
if hook:
self._hook = hook

Expand Down Expand Up @@ -839,6 +840,15 @@ async def received_message(self, msg):
self._keep_alive = VoiceKeepAliveHandler(ws=self, interval=min(interval, 5.0))
self._keep_alive.start()

elif op == self.SPEAKING:
ssrc = data['ssrc']
user = int(data['user_id'])
speaking = data['speaking']
if ssrc in self.ssrc_map:
self.ssrc_map[ssrc]['speaking'] = speaking
else:
self.ssrc_map.update({ssrc: {'user_id': user, 'speaking': speaking}})

await self._hook(self, msg)

async def initial_connection(self, data):
Expand Down
Loading

0 comments on commit e58dd4d

Please sign in to comment.