This commit is contained in:
Daniil Gentili 2019-05-11 18:17:42 +02:00
parent fcad92d7cb
commit 240910475f
6 changed files with 12 additions and 30 deletions

View File

@ -46,6 +46,10 @@ class EventHandler extends APIFactory
public function __set($name, $value)
{
if ($name === 'settings') {
if ($this->API->phoneConfigWatcherId) {
$this->wait($this->API->phoneConfigWatcherId);
$this->API->phoneConfigWatcherId = null;
}
if (Magic::is_fork() && !Magic::$processed_fork) {
\danog\MadelineProto\Logger::log('Detected fork');
$this->API->reset_session();

View File

@ -854,11 +854,6 @@ class MTProto implements TLCallback
}
}
public function get_config($config = [], $options = [])
{
return $this->wait($this->get_config_async($config, $options));
}
public function get_config_async($config = [], $options = [])
{
if ($this->config['expires'] > time()) {
@ -870,10 +865,6 @@ class MTProto implements TLCallback
return $this->config;
}
public function get_cdn_config($datacenter)
{
return $this->wait($this->get_cdn_config_async($datacenter));
}
public function get_cdn_config_async($datacenter)
{
/*
@ -930,10 +921,6 @@ class MTProto implements TLCallback
$this->datacenter->curdc = $curdc;
}
public function get_self()
{
return $this->wait($this->get_self_async());
}
public function get_self_async()
{
try {

View File

@ -207,7 +207,7 @@ trait Files
return $res;
}
public function get_file_info($constructor, $regenerate = false)
public function get_file_info_async($constructor, $regenerate = false)
{
if (is_string($constructor)) {
$constructor = $this->unpack_file_id($constructor)['MessageMedia'];
@ -223,7 +223,7 @@ trait Files
$constructor = $constructor['media'];
}
return $this->gen_all_file($constructor, $regenerate);
return yield $this->gen_all_file_async($constructor, $regenerate);
}
public function get_download_info_async($message_media)
@ -290,7 +290,7 @@ trait Files
}
}
if (!isset($res['ext'])) {
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], $this->get_extension_from_mime(isset($res['mime']) ? $res['mime'] : 'image/jpeg'));
$res['ext'] = $this->get_extension_from_location($res['InputFileLocation'], $this->get_extension_from_mime(isset($res['mime']) ? $res['mime'] : 'image/jpeg'));
}
if (!isset($res['mime'])) {
$res['mime'] = $this->get_mime_from_extension($res['ext'], 'image/jpeg');
@ -348,7 +348,7 @@ trait Files
case 'fileLocation':
$res['name'] = $message_media['volume_id'].'_'.$message_media['local_id'];
$res['InputFileLocation'] = ['_' => 'inputFileLocation', 'volume_id' => $message_media['volume_id'], 'local_id' => $message_media['local_id'], 'secret' => $message_media['secret'], 'dc_id' => $message_media['dc_id'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION_LOCATION, $message_media)];
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], '.jpg');
$res['ext'] = $this->get_extension_from_location($res['InputFileLocation'], '.jpg');
$res['mime'] = $this->get_mime_from_extension($res['ext'], 'image/jpeg');
return $res;
@ -382,7 +382,7 @@ trait Files
}
$res['InputFileLocation'] = ['_' => 'inputDocumentFileLocation', 'id' => $message_media['document']['id'], 'access_hash' => $message_media['document']['access_hash'], 'version' => isset($message_media['document']['version']) ? $message_media['document']['version'] : 0, 'dc_id' => $message_media['document']['dc_id'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION_LOCATION, $message_media['document'])];
if (!isset($res['ext'])) {
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], $this->get_extension_from_mime($message_media['document']['mime_type']));
$res['ext'] = $this->get_extension_from_location($res['InputFileLocation'], $this->get_extension_from_mime($message_media['document']['mime_type']));
}
if (!isset($res['name'])) {
$res['name'] = $message_media['document']['access_hash'];

View File

@ -72,7 +72,7 @@ trait BotAPIFiles
public function photosize_to_botapi_async($photoSize, $photo, $thumbnail = false)
{
$ext = yield $this->get_extension_from_location_async(['_' => 'inputFileLocation', 'volume_id' => $photoSize['location']['volume_id'], 'local_id' => $photoSize['location']['local_id'], 'secret' => $photoSize['location']['secret'], 'dc_id' => $photoSize['location']['dc_id']], '.jpg');
$ext = $this->get_extension_from_location(['_' => 'inputFileLocation', 'volume_id' => $photoSize['location']['volume_id'], 'local_id' => $photoSize['location']['local_id'], 'secret' => $photoSize['location']['secret'], 'dc_id' => $photoSize['location']['dc_id']], '.jpg');
$photoSize['location']['access_hash'] = isset($photo['access_hash']) ? $photo['access_hash'] : 0;
$photoSize['location']['id'] = isset($photo['id']) ? $photo['id'] : 0;
$photoSize['location']['_'] = $thumbnail ? 'bot_thumbnail' : 'bot_photo';

View File

@ -40,10 +40,10 @@ trait Extension
return '';
}
public function get_extension_from_location_async($location, $default)
public function get_extension_from_location($location, $default)
{
return $default;
$res = yield $this->method_call_async_read('upload.getFile', ['location' => $location, 'offset' => 0, 'limit' => 2], ['heavy' => true, 'datacenter' => $location['dc_id']]);
//('upload.getFile', ['location' => $location, 'offset' => 0, 'limit' => 2], ['heavy' => true, 'datacenter' => $location['dc_id']]);
if (!isset($res['type']['_'])) {
return $default;
}

View File

@ -433,15 +433,6 @@ trait TL
return $concat.yield $this->serialize_params_async($constructorData, $object, '', $layer);
}
public function serialize_object($type, $object, $ctx, $layer = -1)
{
return $this->wait($this->serialize_object_async($type, $object, $ctx, $layer));
}
public function serialize_method($method, $arguments)
{
return $this->wait($this->serialize_method_async($method, $arguments));
}
public function serialize_method_async($method, $arguments)
{
if ($method === 'messages.importChatInvite' && isset($arguments['hash']) && is_string($arguments['hash']) && preg_match('@(?:t|telegram)\.(?:me|dog)/(joinchat/)?([a-z0-9_-]*)@i', $arguments['hash'], $matches)) {