From e4a3fc948463ef21b45d90322e3957e059197761 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 31 Jul 2017 19:00:11 +0000 Subject: [PATCH 1/9] Apply fixes from StyleCI --- src/danog/MadelineProto/VoIP/AuthKeyHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php index 64d02a32..5369b03c 100644 --- a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php +++ b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php @@ -212,6 +212,7 @@ trait AuthKeyHandler 'endpoints' => array_merge([$params['connection']], $params['alternative_connections']), ], $this->calls[$params['id']]->configuration); $this->calls[$params['id']]->parseConfig(); + return $this->calls[$params['id']]->startTheMagic(); } From 5cc6719c3d41eaa94a2e74296661d14f6c54eae7 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 1 Aug 2017 11:59:07 +0200 Subject: [PATCH 2/9] Fixes I guess --- src/danog/MadelineProto/MTProtoTools/Files.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/danog/MadelineProto/MTProtoTools/Files.php b/src/danog/MadelineProto/MTProtoTools/Files.php index d938db7c..e65b1896 100644 --- a/src/danog/MadelineProto/MTProtoTools/Files.php +++ b/src/danog/MadelineProto/MTProtoTools/Files.php @@ -301,6 +301,7 @@ trait Files } if ($res['_'] === 'upload.fileCdnRedirect') { $cdn = true; + $this->get_config([], ['datacenter' => $this->datacenter->curdc]); $message_media['file_token'] = $res['file_token']; $message_media['cdn_key'] = $res['encryption_key']; $message_media['cdn_iv'] = $res['encryption_iv']; @@ -311,6 +312,7 @@ trait Files } if ($res['_'] === 'upload.cdnFileReuploadNeeded') { \danog\MadelineProto\Logger::log(['File is not stored on CDN, requesting reupload!'], \danog\MadelineProto\Logger::NOTICE); + $this->get_config([], ['datacenter' => $this->datacenter->curdc]); try { $this->add_cdn_hashes($message_media['file_token'], $this->method_call('upload.reuploadCdnFile', ['file_token' => $message_media['file_token'], 'request_token' => $res['request_token']], ['heavy' => true, 'datacenter' => $old_dc])); } catch (\danog\MadelineProto\RPCErrorException $e) { From 5a2a515f3310c7e5ee7daa6139dd31bbc3c67aed Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 1 Aug 2017 12:17:53 +0200 Subject: [PATCH 3/9] fixes --- bot.php | 2 +- src/danog/MadelineProto/MTProtoTools/Files.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bot.php b/bot.php index 8e2e6ecc..7666e301 100755 --- a/bot.php +++ b/bot.php @@ -48,7 +48,7 @@ while (true) { $res = var_export($update, true); } try { - $MadelineProto->messages->sendMessage(['peer' => $update['update']['_'] === 'updateNewMessage' ? $update['update']['message']['from_id'] : $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]); +// $MadelineProto->messages->sendMessage(['peer' => $update['update']['_'] === 'updateNewMessage' ? $update['update']['message']['from_id'] : $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]); } catch (\danog\MadelineProto\RPCErrorException $e) { $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]); } diff --git a/src/danog/MadelineProto/MTProtoTools/Files.php b/src/danog/MadelineProto/MTProtoTools/Files.php index e65b1896..1cb2d422 100644 --- a/src/danog/MadelineProto/MTProtoTools/Files.php +++ b/src/danog/MadelineProto/MTProtoTools/Files.php @@ -301,12 +301,15 @@ trait Files } if ($res['_'] === 'upload.fileCdnRedirect') { $cdn = true; - $this->get_config([], ['datacenter' => $this->datacenter->curdc]); $message_media['file_token'] = $res['file_token']; $message_media['cdn_key'] = $res['encryption_key']; $message_media['cdn_iv'] = $res['encryption_iv']; $old_dc = $datacenter; $datacenter = $res['dc_id'].'_cdn'; + if (!isset($this->datacenter->sockets[$datacenter])) { + $this->config['expires'] = -1; + $this->get_config([], ['datacenter' => $this->datacenter->curdc]); + } \danog\MadelineProto\Logger::log(['File is stored on CDN!'], \danog\MadelineProto\Logger::NOTICE); continue; } From 1c742559ccc817aa1ce7809615c7bbf033e724ef Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 1 Aug 2017 10:18:14 +0000 Subject: [PATCH 4/9] Apply fixes from StyleCI --- bot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.php b/bot.php index 7666e301..aa0e90fd 100755 --- a/bot.php +++ b/bot.php @@ -48,7 +48,7 @@ while (true) { $res = var_export($update, true); } try { -// $MadelineProto->messages->sendMessage(['peer' => $update['update']['_'] === 'updateNewMessage' ? $update['update']['message']['from_id'] : $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]); + // $MadelineProto->messages->sendMessage(['peer' => $update['update']['_'] === 'updateNewMessage' ? $update['update']['message']['from_id'] : $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]); } catch (\danog\MadelineProto\RPCErrorException $e) { $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]); } From 04e1b8c4d7897467a6ad29412786390bac11b42f Mon Sep 17 00:00:00 2001 From: giuseppeM99 Date: Wed, 2 Aug 2017 15:12:18 +0200 Subject: [PATCH 5/9] Gotta catch 'em all!!! (#164) * Update get_dialogs * Gotta catch 'em all!!! --- .gitignore | 1 + src/danog/MadelineProto/APIFactory.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 3be7bbee..8af63c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,7 @@ token.php *~uploading* session.mad *.madeline +*.madeline.lock enc.tar.xz a web_data.php diff --git a/src/danog/MadelineProto/APIFactory.php b/src/danog/MadelineProto/APIFactory.php index e9896a10..b12a391e 100644 --- a/src/danog/MadelineProto/APIFactory.php +++ b/src/danog/MadelineProto/APIFactory.php @@ -143,6 +143,16 @@ class APIFactory return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; } catch (\danog\MadelineProto\RPCErrorException $e) { return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; + } catch (\danog\MadelineProto\TL\Exception $e) { + return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; + } catch (\danog\MadelineProto\NothingInTheSocketException $e) { + return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; + } catch (\danog\MadelineProto\PTSException $e) { + return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; + } catch (\danog\MadelineProto\SecurityException $e) { + return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; + } catch (\danog\MadelineProto\TL\Conversion\Exception $e) { + return ['error_code' => $e->getCode(), 'error' => $e->getMessage()]; } } } From 03df1074398c3bdbe121eedff86c907e62d159f0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Aug 2017 15:01:22 +0430 Subject: [PATCH 6/9] Fixes to CDN files --- src/danog/MadelineProto/DataCenter.php | 1 + src/danog/MadelineProto/MTProto.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/DataCenter.php b/src/danog/MadelineProto/DataCenter.php index 822bba63..81dcb5b6 100644 --- a/src/danog/MadelineProto/DataCenter.php +++ b/src/danog/MadelineProto/DataCenter.php @@ -46,6 +46,7 @@ var_dump(is_null($this->{$name})); $this->settings = $settings; foreach ($this->sockets as $key => $socket) { if ($socket instanceof Connection) { + \danog\MadelineProto\Logger::log(['Connecting to DC '.$key.'...'], \danog\MadelineProto\Logger::VERBOSE); $socket->old = true; $socket->close_and_reopen(); } else { diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 56fd6d0a..5ac61767 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -777,7 +777,11 @@ class MTProto extends \Volatile unset($dc['ipv6']); $this->settings['connection'][$test][$ipv6][$id] = $dc; } - $this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']); + $curdc = $this->datacenter->curdc; + $this->datacenter->dclist = $this->settings['connection']; + $this->datacenter->settings = $this->settings['connection_settings']; + $this->connect_to_all_dcs(); + $this->datacenter->curdc = $curdc; } public function get_self() From 79dc591f4f3fdd174e4530a18a9495afbcea895f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 3 Aug 2017 17:24:38 +0200 Subject: [PATCH 7/9] Added docs for setBitrate --- docs/API_docs/types/PhoneCall.md | 1 + old_docs/API_docs_v62/types/PhoneCall.md | 1 + old_docs/API_docs_v65/types/PhoneCall.md | 1 + old_docs/API_docs_v66/types/PhoneCall.md | 1 + old_docs/API_docs_v68/types/PhoneCall.md | 1 + 5 files changed, 5 insertions(+) diff --git a/docs/API_docs/types/PhoneCall.md b/docs/API_docs/types/PhoneCall.md index 668c475e..cb9cc822 100644 --- a/docs/API_docs/types/PhoneCall.md +++ b/docs/API_docs/types/PhoneCall.md @@ -146,6 +146,7 @@ The audio configuration is an array structured in the following way: * `playOnHold(array $files)` - Array of audio files encoded in PCM, with the audio input configuration to loop on hold (when the files given with play/then have finished playing). If not called, no data will be played, returns `$this` * `isPlaying()` - Returns true if MadelineProto is still playing the files given with play/then, false if the hold files (or nothing) is being played * `setMicMute(bool $mute)` - Stops/resumes playing files/hold files, returns `$this` +* `setBitrate(int $bitrate)` - Sets maximum outgoing bitrate, and increases the bitrate of the call to the maximum outgoing bitrate (high values increase the quality of the song), returns `$this` * `setOutputFile(string $outputfile)` - Writes incoming audio data to file encoded in PCM, with the audio output configuration, returns `$this` * `unsetOutputFile()` - Stops writing audio data to previously set file, returns `$this` diff --git a/old_docs/API_docs_v62/types/PhoneCall.md b/old_docs/API_docs_v62/types/PhoneCall.md index 668c475e..cb9cc822 100644 --- a/old_docs/API_docs_v62/types/PhoneCall.md +++ b/old_docs/API_docs_v62/types/PhoneCall.md @@ -146,6 +146,7 @@ The audio configuration is an array structured in the following way: * `playOnHold(array $files)` - Array of audio files encoded in PCM, with the audio input configuration to loop on hold (when the files given with play/then have finished playing). If not called, no data will be played, returns `$this` * `isPlaying()` - Returns true if MadelineProto is still playing the files given with play/then, false if the hold files (or nothing) is being played * `setMicMute(bool $mute)` - Stops/resumes playing files/hold files, returns `$this` +* `setBitrate(int $bitrate)` - Sets maximum outgoing bitrate, and increases the bitrate of the call to the maximum outgoing bitrate (high values increase the quality of the song), returns `$this` * `setOutputFile(string $outputfile)` - Writes incoming audio data to file encoded in PCM, with the audio output configuration, returns `$this` * `unsetOutputFile()` - Stops writing audio data to previously set file, returns `$this` diff --git a/old_docs/API_docs_v65/types/PhoneCall.md b/old_docs/API_docs_v65/types/PhoneCall.md index 668c475e..cb9cc822 100644 --- a/old_docs/API_docs_v65/types/PhoneCall.md +++ b/old_docs/API_docs_v65/types/PhoneCall.md @@ -146,6 +146,7 @@ The audio configuration is an array structured in the following way: * `playOnHold(array $files)` - Array of audio files encoded in PCM, with the audio input configuration to loop on hold (when the files given with play/then have finished playing). If not called, no data will be played, returns `$this` * `isPlaying()` - Returns true if MadelineProto is still playing the files given with play/then, false if the hold files (or nothing) is being played * `setMicMute(bool $mute)` - Stops/resumes playing files/hold files, returns `$this` +* `setBitrate(int $bitrate)` - Sets maximum outgoing bitrate, and increases the bitrate of the call to the maximum outgoing bitrate (high values increase the quality of the song), returns `$this` * `setOutputFile(string $outputfile)` - Writes incoming audio data to file encoded in PCM, with the audio output configuration, returns `$this` * `unsetOutputFile()` - Stops writing audio data to previously set file, returns `$this` diff --git a/old_docs/API_docs_v66/types/PhoneCall.md b/old_docs/API_docs_v66/types/PhoneCall.md index 668c475e..cb9cc822 100644 --- a/old_docs/API_docs_v66/types/PhoneCall.md +++ b/old_docs/API_docs_v66/types/PhoneCall.md @@ -146,6 +146,7 @@ The audio configuration is an array structured in the following way: * `playOnHold(array $files)` - Array of audio files encoded in PCM, with the audio input configuration to loop on hold (when the files given with play/then have finished playing). If not called, no data will be played, returns `$this` * `isPlaying()` - Returns true if MadelineProto is still playing the files given with play/then, false if the hold files (or nothing) is being played * `setMicMute(bool $mute)` - Stops/resumes playing files/hold files, returns `$this` +* `setBitrate(int $bitrate)` - Sets maximum outgoing bitrate, and increases the bitrate of the call to the maximum outgoing bitrate (high values increase the quality of the song), returns `$this` * `setOutputFile(string $outputfile)` - Writes incoming audio data to file encoded in PCM, with the audio output configuration, returns `$this` * `unsetOutputFile()` - Stops writing audio data to previously set file, returns `$this` diff --git a/old_docs/API_docs_v68/types/PhoneCall.md b/old_docs/API_docs_v68/types/PhoneCall.md index 668c475e..cb9cc822 100644 --- a/old_docs/API_docs_v68/types/PhoneCall.md +++ b/old_docs/API_docs_v68/types/PhoneCall.md @@ -146,6 +146,7 @@ The audio configuration is an array structured in the following way: * `playOnHold(array $files)` - Array of audio files encoded in PCM, with the audio input configuration to loop on hold (when the files given with play/then have finished playing). If not called, no data will be played, returns `$this` * `isPlaying()` - Returns true if MadelineProto is still playing the files given with play/then, false if the hold files (or nothing) is being played * `setMicMute(bool $mute)` - Stops/resumes playing files/hold files, returns `$this` +* `setBitrate(int $bitrate)` - Sets maximum outgoing bitrate, and increases the bitrate of the call to the maximum outgoing bitrate (high values increase the quality of the song), returns `$this` * `setOutputFile(string $outputfile)` - Writes incoming audio data to file encoded in PCM, with the audio output configuration, returns `$this` * `unsetOutputFile()` - Stops writing audio data to previously set file, returns `$this` From b0260809cf1e3c15bbf5b71664bf1a3dcbf38ca9 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 4 Aug 2017 10:01:54 +0200 Subject: [PATCH 8/9] Small cdn fix --- src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index f689a4f0..dd8fb54a 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -414,7 +414,7 @@ trait AuthKeyHandler } } - throw new \danog\MadelineProto\SecurityException('Auth Failed'); + if (strpos($datacenter, 'cdn') === false) throw new \danog\MadelineProto\SecurityException('Auth Failed'); } public function check_G($g_a, $p) From e124806b9f7e67a830db192c3bb0c4d09752cb8e Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 4 Aug 2017 08:02:14 +0000 Subject: [PATCH 9/9] Apply fixes from StyleCI --- src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index dd8fb54a..4b152d74 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -414,7 +414,9 @@ trait AuthKeyHandler } } - if (strpos($datacenter, 'cdn') === false) throw new \danog\MadelineProto\SecurityException('Auth Failed'); + if (strpos($datacenter, 'cdn') === false) { + throw new \danog\MadelineProto\SecurityException('Auth Failed'); + } } public function check_G($g_a, $p)