3535from typing import TYPE_CHECKING , Any
3636
3737import aiohttp
38-
3938import davey
39+
4040from discord import utils
4141from discord .enums import SpeakingState
4242from discord .errors import ConnectionClosed
@@ -152,7 +152,9 @@ async def _hook(self, *args: Any) -> Any:
152152
153153 async def send_as_bytes (self , op : int , data : bytes ) -> None :
154154 packet = bytes (op ) + data
155- _log .debug ("Sending voice websocket binary frame: op: %s data: %s" , op , str (data ))
155+ _log .debug (
156+ "Sending voice websocket binary frame: op: %s data: %s" , op , str (data )
157+ )
156158 await self .ws .send_bytes (packet )
157159
158160 async def send_as_json (self , data : Any ) -> None :
@@ -208,7 +210,10 @@ async def received_message(self, msg: Any, /):
208210 self ._keep_alive .start ()
209211 elif self .dave_session :
210212 if op == OpCodes .dave_prepare_transition :
211- _log .info ("Preparing to upgrade to a DAVE connection for channel %s" , state .channel_id )
213+ _log .info (
214+ "Preparing to upgrade to a DAVE connection for channel %s" ,
215+ state .channel_id ,
216+ )
212217 state .dave_pending_transition = data
213218
214219 transition_id = data ["transition_id" ]
@@ -220,11 +225,17 @@ async def received_message(self, msg: Any, /):
220225 self .dave_session .set_passthrough_mode (True , 120 )
221226 await self .send_dave_transition_ready (transition_id )
222227 elif op == OpCodes .dave_execute_transition :
223- _log .info ("Upgrading to DAVE connection for channel %s" , state .channel_id )
228+ _log .info (
229+ "Upgrading to DAVE connection for channel %s" , state .channel_id
230+ )
224231 await state .execute_dave_transition (data ["transition_id" ])
225232 elif op == OpCodes .dave_prepare_epoch :
226233 epoch = data ["epoch" ]
227- _log .debug ("Preparing for DAVE epoch in channel %s: %s" , state .channel_id , epoch )
234+ _log .debug (
235+ "Preparing for DAVE epoch in channel %s: %s" ,
236+ state .channel_id ,
237+ epoch ,
238+ )
228239 # if epoch is 1 then a new MLS group is to be created for the proto version
229240 if epoch == 1 :
230241 state .dave_protocol_version = data ["protocol_version" ]
@@ -237,7 +248,12 @@ async def received_message(self, msg: Any, /):
237248 async def received_binary_message (self , msg : bytes ) -> None :
238249 self .seq_ack = struct .unpack_from (">H" , msg , 0 )[0 ]
239250 op = msg [2 ]
240- _log .debug ("Voice websocket binary frame received: %d bytes, seq: %s, op: %s" , len (msg ), self .seq_ack , op )
251+ _log .debug (
252+ "Voice websocket binary frame received: %d bytes, seq: %s, op: %s" ,
253+ len (msg ),
254+ self .seq_ack ,
255+ op ,
256+ )
241257
242258 state = self .state
243259
@@ -249,14 +265,22 @@ async def received_binary_message(self, msg: bytes) -> None:
249265 elif op == OpCodes .mls_proposals :
250266 op_type = msg [3 ]
251267 result = self .dave_session .process_proposals (
252- davey .ProposalsOperationType .append if op_type == 0 else davey .ProposalsOperationType .revoke ,
268+ (
269+ davey .ProposalsOperationType .append
270+ if op_type == 0
271+ else davey .ProposalsOperationType .revoke
272+ ),
253273 msg [4 :],
254274 )
255275
256276 if isinstance (result , davey .CommitWelcome ):
257277 await self .send_as_bytes (
258278 OpCodes .mls_key_package .value ,
259- (result .commit + result .welcome ) if result .welcome else result .commit ,
279+ (
280+ (result .commit + result .welcome )
281+ if result .welcome
282+ else result .commit
283+ ),
260284 )
261285 _log .debug ("Processed MLS proposals for current dave session" )
262286 elif op == OpCodes .mls_commit_transition :
@@ -271,7 +295,10 @@ async def received_binary_message(self, msg: bytes) -> None:
271295 await self .send_dave_transition_ready (transt_id )
272296 _log .debug ("Processed MLS commit for transition %s" , transt_id )
273297 except Exception as exc :
274- _log .debug ("An exception ocurred while processing a MLS commit, this should be safe to ignore: %s" , exc )
298+ _log .debug (
299+ "An exception ocurred while processing a MLS commit, this should be safe to ignore: %s" ,
300+ exc ,
301+ )
275302 await state .recover_dave_from_invalid_commit (transt_id )
276303 elif op == OpCodes .mls_welcome :
277304 transt_id = struct .unpack_from (">H" , msg , 3 )[0 ]
@@ -285,7 +312,10 @@ async def received_binary_message(self, msg: bytes) -> None:
285312 await self .send_dave_transition_ready (transt_id )
286313 _log .debug ("Processed MLS welcome for transition %s" , transt_id )
287314 except Exception as exc :
288- _log .debug ("An exception ocurred while processing a MLS welcome, this should be safe to ignore: %s" , exc )
315+ _log .debug (
316+ "An exception ocurred while processing a MLS welcome, this should be safe to ignore: %s" ,
317+ exc ,
318+ )
289319 await state .recover_dave_from_invalid_commit (transt_id )
290320
291321 async def ready (self , data : dict [str , Any ]) -> None :
0 commit comments