This commit is contained in:
Daniil Gentili 2018-12-31 13:09:46 +00:00
parent 06d083aae8
commit b4cecd9fbd
5 changed files with 8 additions and 6 deletions

View File

@ -32,8 +32,8 @@ class EventHandler extends \danog\MadelineProto\EventHandler
if (isset($update['message']['out']) && $update['message']['out']) {
return;
}
if (isset($update['message']['media'])) {
yield $MadelineProto->download_to_dir($update, '/tmp');
if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') {
//yield $this->download_to_dir($update, '/tmp');
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $update]);
}

View File

@ -32,6 +32,7 @@ class API extends APIFactory
public function __magic_construct($params = [], $settings = [])
{
Magic::class_exists();
set_error_handler(['\\danog\\MadelineProto\\Exception', 'ExceptionErrorHandler']);
if (is_string($params)) {
$realpaths = Serialization::realpaths($params);

View File

@ -185,7 +185,7 @@ class APIFactory
{
$result = $this->methods[$name](...$arguments);
if (is_object($result) && ($result instanceof \Generator || $result instanceof Promise)) {
$async = isset(end($arguments)['async']) ? end($arguments)['async'] : $this->async;
$async = is_array(end($arguments)) && isset(end($arguments)['async']) ? end($arguments)['async'] : $this->async;
if ($async && ($name !== 'loop' || isset(end($arguments)['async']))) {
return $result;
} else {

View File

@ -29,7 +29,6 @@ class Absolute
if (($file[0] !== '/') && ($file[1] !== ':') && !in_array(substr($file, 0, 4), ['phar', 'http'])) {
$file = Magic::getcwd().'/'.$file;
}
return $file;
}
}

View File

@ -79,7 +79,7 @@ class ReadLoop extends SignalLoop
foreach ($connection->new_outgoing as $message_id) {
$connection->outgoing_messages[$message_id]['sent'] = 0;
}
$API->init_authorization();
yield $API->init_authorization_async();
} else {
//throw new \danog\MadelineProto\RPCErrorException($error, $error);
}
@ -102,6 +102,7 @@ class ReadLoop extends SignalLoop
$this->exitedLoop();
}
$this->startedLoop();
//var_dump(count($connection->incoming_messages));
// Loop::defer(function () use ($datacenter) {
if ($this->API->is_http($datacenter)) {
$this->API->datacenter->sockets[$datacenter]->waiter->resume();
@ -202,7 +203,8 @@ class ReadLoop extends SignalLoop
}
$connection->incoming_messages[$message_id] = ['seq_no' => $seq_no];
} else {
throw new \danog\MadelineProto\Exception('Got unknown auth_key id');
$API->logger->logger('Got unknown auth_key id', \danog\MadelineProto\Logger::ERROR);
return -404;
}
$deserialized = $API->deserialize($message_data, ['type' => '', 'datacenter' => $datacenter]);
$API->referenceDatabase->reset();