From 2d2a3bd01f309e60a702370f6d55b41d7e5f66f8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 22 Jun 2019 16:34:46 +0200 Subject: [PATCH] Wrap wait --- src/danog/MadelineProto/MyTelegramOrgWrapper.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/MyTelegramOrgWrapper.php b/src/danog/MadelineProto/MyTelegramOrgWrapper.php index d2e7bb74..76ec2399 100644 --- a/src/danog/MadelineProto/MyTelegramOrgWrapper.php +++ b/src/danog/MadelineProto/MyTelegramOrgWrapper.php @@ -258,12 +258,18 @@ class MyTelegramOrgWrapper { $this->async = $async; } - + public function loop($callable) + { + return $this->wait($callable()); + } public function __call($name, $arguments) { $name .= '_async'; $async = is_array(end($arguments)) && isset(end($arguments)['async']) ? end($arguments)['async'] : $this->async; + if (!method_exists($this, $name)) { + throw new Exception("$name does not exist!"); + } return $async ? $this->{$name}(...$arguments) : $this->wait($this->{$name}(...$arguments)); } }