Lua fixes
This commit is contained in:
parent
3024dc4a15
commit
ade8c07a2c
@ -136,18 +136,7 @@ class APIFactory
|
||||
}
|
||||
try {
|
||||
$deserialized = method_exists($this->API, $this->namespace.$name) ? $this->API->{$this->namespace.$name}(...$arguments) : $this->API->method_call($this->namespace.$name, (isset($arguments[0]) && $this->is_array($arguments[0])) ? $arguments[0] : [], $aargs);
|
||||
array_walk_recursive($deserialized, function (&$value, $key) {
|
||||
if (is_object($value)) {
|
||||
$newval = [];
|
||||
foreach (get_class_methods($value) as $key => $name) {
|
||||
$newval[$key] = [$value, $name];
|
||||
}
|
||||
foreach ($value as $key => $name) {
|
||||
$newval[$key] = $name;
|
||||
}
|
||||
$value = $newval;
|
||||
}
|
||||
});
|
||||
Lua::convert_objects($deserialized);
|
||||
|
||||
return $deserialized;
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
|
@ -84,18 +84,7 @@ class Lua
|
||||
if (is_callable($cb)) {
|
||||
$cb($result, $cb_extra);
|
||||
}
|
||||
array_walk_recursive($result, function (&$value, $key) {
|
||||
if (is_object($value)) {
|
||||
$newval = [];
|
||||
foreach (get_class_methods($value) as $key => $name) {
|
||||
$newval[$key] = [$value, $name];
|
||||
}
|
||||
foreach ($value as $key => $name) {
|
||||
$newval[$key] = $name;
|
||||
}
|
||||
$value = $newval;
|
||||
}
|
||||
});
|
||||
self::convert_objects($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -137,18 +126,7 @@ class Lua
|
||||
|
||||
public function __call($name, $params)
|
||||
{
|
||||
array_walk_recursive($params, function (&$value, $key) {
|
||||
if (is_object($value)) {
|
||||
$newval = [];
|
||||
foreach (get_class_methods($value) as $key => $name) {
|
||||
$newval[$key] = [$value, $name];
|
||||
}
|
||||
foreach ($value as $key => $name) {
|
||||
$newval[$key] = $name;
|
||||
}
|
||||
$value = $newval;
|
||||
}
|
||||
});
|
||||
self::convert_objects($params);
|
||||
try {
|
||||
return $this->Lua->{$name}(...$params);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
@ -172,4 +150,19 @@ class Lua
|
||||
{
|
||||
return $this->Lua->{$name} = $value;
|
||||
}
|
||||
public static function convert_objects(&$data) {
|
||||
array_walk_recursive($data, function (&$value, $key) {
|
||||
if (is_object($value)) {
|
||||
$newval = [];
|
||||
foreach (get_class_methods($value) as $key => $name) {
|
||||
$newval[$key] = [$value, $name];
|
||||
}
|
||||
foreach ($value as $key => $name) {
|
||||
$newval[$key] = $name;
|
||||
}
|
||||
if ($newval === []) $newval = $value->__toString();
|
||||
$value = $newval;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user