async def _join_voice_call(self, params: dict): request_call = { 'ufrag': params['ufrag'], 'pwd': params['pwd'], 'fingerprints': [{ 'hash': params['hash'], 'setup': params['setup'], 'fingerprint': params['fingerprint'], }], 'ssrc': params['source'], } print(request_call) chat_call = None # noinspection PyBroadException try: chat_call = await self.pytgcalls._load_chat_call( int(params['chat_id']), ) except Exception: pass if chat_call is not None: try: result: Updates = await self.pytgcalls._app.send( JoinGroupCall( call=chat_call, params=DataJSON(data=json.dumps(request_call)), muted=False, join_as=self.pytgcalls._cache_user_peer[ int(params['chat_id']) ], invite_hash=params['invite_hash'], ), ) transport = json.loads(result.updates[0].call.params.data)[ 'transport' ] return { 'transport': { 'ufrag': transport['ufrag'], 'pwd': transport['pwd'], 'fingerprints': transport['fingerprints'], 'candidates': transport['candidates'], }, } except Exception as e: if 'GROUPCALL_FORBIDDEN' in str(e): if int(params['chat_id']) in \ self.pytgcalls._cache_full_chat: del self.pytgcalls._cache_full_chat[ int( params['chat_id'], ) ] if self.pytgcalls._log_mode > 0: print('JOIN_VOICE_CALL_ERROR ->', e) return {'transport': None}
async def _join_voice_call(self, request: BaseRequest): params = await request.json() if isinstance(params, str): params = json.loads(params) request_call = { 'ufrag': params['ufrag'], 'pwd': params['pwd'], 'fingerprints': [{ 'hash': params['hash'], 'setup': params['setup'], 'fingerprint': params['fingerprint'], }], 'ssrc': params['source'], } chat_call = None # noinspection PyBroadException try: chat_call = (await self.pytgcalls._load_full_chat(params['chat_id'] )).full_chat.call except Exception: pass if chat_call is not None: try: result: Updates = await self.pytgcalls._app.send( JoinGroupCall( call=chat_call, params=DataJSON(data=json.dumps(request_call)), muted=False, ), ) transport = json.loads( result.updates[0].call.params.data)['transport'] result_json = { 'transport': { 'ufrag': transport['ufrag'], 'pwd': transport['pwd'], 'fingerprints': transport['fingerprints'], 'candidates': transport['candidates'], }, } except Exception as e: if 'GROUPCALL_FORBIDDEN' not in str(e): print(e) result_json = { 'transport': None, } else: result_json = { 'transport': None, } return web.json_response(result_json)
async def join_group_call( self, chat_id: int, json_join: dict, invite_hash: str, have_video: bool, join_as: InputPeer, ) -> dict: chat_call = await self._cache.get_full_chat(chat_id) if chat_call is not None: result: Updates = await self._app.send( JoinGroupCall( call=chat_call, params=DataJSON(data=json.dumps(json_join)), muted=False, join_as=join_as, video_stopped=have_video, invite_hash=invite_hash, ), ) for update in result.updates: if isinstance( update, UpdateGroupCallParticipants, ): participants = update.participants for participant in participants: self._cache.set_participants_cache( update.call.id, self.chat_id(participant.peer), participant.muted, participant.volume, participant.can_self_unmute, participant.video is not None or participant.presentation is not None, participant.presentation is not None, participant.video is not None, participant.raise_hand_rating, participant.left, ) if isinstance(update, UpdateGroupCallConnection): transport = json.loads(update.params.data)[ 'transport' ] return { 'transport': { 'ufrag': transport['ufrag'], 'pwd': transport['pwd'], 'fingerprints': transport['fingerprints'], 'candidates': transport['candidates'], }, } return {'transport': None}
async def _join_voice_call(self, request: BaseRequest): params = await request.json() if isinstance(params, str): params = json.loads(params) request_call = { 'ufrag': params['ufrag'], 'pwd': params['pwd'], 'fingerprints': [{ 'hash': params['hash'], 'setup': params['setup'], 'fingerprint': params['fingerprint'], }], 'ssrc': params['source'], } chat_call = None # noinspection PyBroadException try: chat_call = (await self.pytgcalls._load_full_chat(int(params['chat_id']) )).full_chat.call except Exception: pass if chat_call is not None: try: result: Updates = await self.pytgcalls._app.send( JoinGroupCall( call=chat_call, params=DataJSON(data=json.dumps(request_call)), muted=False, join_as=self.pytgcalls._cache_user_peer[int( params['chat_id'])], invite_hash=params['invite_hash'], ), ) transport = json.loads( result.updates[0].call.params.data)['transport'] return web.json_response({ 'transport': { 'ufrag': transport['ufrag'], 'pwd': transport['pwd'], 'fingerprints': transport['fingerprints'], 'candidates': transport['candidates'], }, }) except Exception as e: if self.pytgcalls._log_mode > 0: print('JOIN_VOICE_CALL_ERROR ->', e) return web.json_response({'transport': None})