This commit is contained in:
Daniil Gentili 2017-08-04 08:23:28 +00:00
commit 296dcb8147
13 changed files with 32 additions and 3 deletions

1
.gitignore vendored
View File

@ -76,6 +76,7 @@ token.php
*~uploading*
session.mad
*.madeline
*.madeline.lock
enc.tar.xz
a
web_data.php

View File

@ -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()]);
}

View File

@ -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`

View File

@ -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`

View File

@ -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`

View File

@ -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`

View File

@ -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`

View File

@ -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()];
}
}
}

View File

@ -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 {

View File

@ -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()

View File

@ -414,7 +414,9 @@ 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)

View File

@ -306,11 +306,16 @@ trait Files
$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;
}
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) {

View File

@ -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();
}