mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 09:34:38 +01:00
Multiple args
This commit is contained in:
parent
61114c6a92
commit
387584a178
@ -61,7 +61,7 @@ trait CallHandler
|
||||
$this->datacenter->sockets[$new_datacenter]->writer->resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function method_call($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false])
|
||||
{
|
||||
return $this->wait($this->method_call_async_read($method, $args, $aargs));
|
||||
@ -111,14 +111,17 @@ trait CallHandler
|
||||
|
||||
if (is_array($args)) {
|
||||
if (isset($args['message']) && is_string($args['message']) && mb_strlen($args['message'], 'UTF-8') > $this->config['message_length_max']) {
|
||||
$arg_chunks = yield $this->split_to_chunks_async($args);
|
||||
$args = yield $this->split_to_chunks_async($args);
|
||||
$promises = [];
|
||||
$aargs['queue'] = $method;
|
||||
$aargs['multiple'] = true;
|
||||
}
|
||||
if (isset($aargs['multiple'])) {
|
||||
$new_aargs = $aargs;
|
||||
$new_aargs['postpone'] = true;
|
||||
$new_aargs['queue'] = $method;
|
||||
|
||||
foreach ($arg_chunks as $args) {
|
||||
$promises[] = $this->method_call_async_write($method, $args, $new_aargs);
|
||||
unset($new_aargs['multiple']);
|
||||
foreach ($args as $single_args) {
|
||||
$promises[] = $this->method_call_async_write($method, $single_args, $new_aargs);
|
||||
}
|
||||
|
||||
if (!isset($aargs['postpone'])) {
|
||||
|
@ -311,4 +311,11 @@ trait Tools
|
||||
{
|
||||
return new \Amp\Delayed($time * 1000);
|
||||
}
|
||||
public function is_array_or_alike($var)
|
||||
{
|
||||
return is_array($var) ||
|
||||
($var instanceof ArrayAccess &&
|
||||
$var instanceof Traversable &&
|
||||
$var instanceof Countable);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user