This commit is contained in:
Daniil Gentili 2020-03-03 00:08:39 +01:00
parent c0af617862
commit 80f162a116
8 changed files with 35 additions and 28 deletions

View File

@ -177,6 +177,7 @@ You can find examples for nearly every MadelineProto function in
* [SignalLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#signalloop) * [SignalLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#signalloop)
* [ResumableSignalLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#resumablesignalloop) * [ResumableSignalLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#resumablesignalloop)
* [GenericLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#genericloop) * [GenericLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#genericloop)
* [PeriodicLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#periodicloop)
* [Using methods](https://docs.madelineproto.xyz/docs/USING_METHODS.html) * [Using methods](https://docs.madelineproto.xyz/docs/USING_METHODS.html)
* [FULL API Documentation with descriptions](https://docs.madelineproto.xyz/API_docs/methods/) * [FULL API Documentation with descriptions](https://docs.madelineproto.xyz/API_docs/methods/)
* [Logout](https://docs.madelineproto.xyz/logout.html) * [Logout](https://docs.madelineproto.xyz/logout.html)

2
docs

@ -1 +1 @@
Subproject commit aba1bf55122500b13163d9589404d4cb7ca49c1b Subproject commit 37ab58024569319076d063cf37f58b6e22e22418

View File

@ -5419,21 +5419,6 @@ class InternalDoc extends APIFactory
{ {
\danog\MadelineProto\MTProto::setVar($obj, $var, $val); \danog\MadelineProto\MTProto::setVar($obj, $var, $val);
} }
/**
* Discard call.
*
* @param array $call Call
* @param string $reason Discard reason
* @param array $rating Rating
* @param boolean $need_debug Need debug?
*
* @return \Generator
*/
public function discardCall(array $call, array $reason, array $rating = [
], bool $need_debug = true, array $extra = [])
{
return $this->__call(__FUNCTION__, [$call, $reason, $rating, $need_debug, $extra]);
}
/** /**
* Request VoIP call. * Request VoIP call.
* *
@ -5500,6 +5485,21 @@ class InternalDoc extends APIFactory
{ {
return $this->API->getCall($call); return $this->API->getCall($call);
} }
/**
* Discard call.
*
* @param array $call Call
* @param string $reason Discard reason
* @param array $rating Rating
* @param boolean $need_debug Need debug?
*
* @return \Generator
*/
public function discardCall(array $call, array $reason, array $rating = [
], bool $need_debug = true, array $extra = [])
{
return $this->__call(__FUNCTION__, [$call, $reason, $rating, $need_debug, $extra]);
}
/** /**
* Check state of calls. * Check state of calls.
* *
@ -5709,18 +5709,18 @@ class InternalDoc extends APIFactory
* *
* @return void * @return void
*/ */
public function stop(): void public function stop(array $extra = [])
{ {
$this->API->stop(); return $this->__call(__FUNCTION__, [$extra]);
} }
/** /**
* Restart update loop. * Restart update loop.
* *
* @return void * @return void
*/ */
public function restart(): void public function restart(array $extra = [])
{ {
$this->API->restart(); return $this->__call(__FUNCTION__, [$extra]);
} }
/** /**
* Start MadelineProto's update handling loop in background. * Start MadelineProto's update handling loop in background.
@ -5738,9 +5738,9 @@ class InternalDoc extends APIFactory
* *
* @return void * @return void
*/ */
public function closeConnection($message = 'OK!'): void public function closeConnection($message = 'OK!', array $extra = [])
{ {
$this->API->closeConnection($message); return $this->__call(__FUNCTION__, [$message, $extra]);
} }
/** /**
* Set NOOP update handler, ignoring all updates. * Set NOOP update handler, ignoring all updates.

View File

@ -372,7 +372,7 @@ trait UpdateHandler
if (!isset($this->calls[$update['phone_call']['id']])) { if (!isset($this->calls[$update['phone_call']['id']])) {
return; return;
} }
return $this->calls[$update['phone_call']['id']]->discard($update['phone_call']['reason'], [], $update['phone_call']['need_debug']); return $this->calls[$update['phone_call']['id']]->discard($update['phone_call']['reason'] ?? '', [], $update['phone_call']['need_debug'] ?? false);
} }
} }
if ($update['_'] === 'updateNewEncryptedMessage' && !isset($update['message']['decrypted_message'])) { if ($update['_'] === 'updateNewEncryptedMessage' && !isset($update['message']['decrypted_message'])) {

View File

@ -36,6 +36,8 @@ trait AuthKeyHandler
* @param \danog\MadelineProto\VoIP $instance Call instance * @param \danog\MadelineProto\VoIP $instance Call instance
* @param array $user User * @param array $user User
* *
* @internal
*
* @return mixed * @return mixed
*/ */
public function acceptCallFrom($instance, $user) public function acceptCallFrom($instance, $user)
@ -61,6 +63,8 @@ trait AuthKeyHandler
* @param array $rating Rating * @param array $rating Rating
* @param boolean $need_debug Needs debug? * @param boolean $need_debug Needs debug?
* *
* @internal
*
* @return mixed * @return mixed
*/ */
public function discardCallFrom($instance, $call, $reason, $rating = [], $need_debug = true) public function discardCallFrom($instance, $call, $reason, $rating = [], $need_debug = true)

View File

@ -85,7 +85,7 @@ trait Events
$this->settings['updates']['callback'] = [$this, 'eventUpdateHandler']; $this->settings['updates']['callback'] = [$this, 'eventUpdateHandler'];
$this->settings['updates']['handle_updates'] = true; $this->settings['updates']['handle_updates'] = true;
$this->settings['updates']['run_callback'] = true; $this->settings['updates']['run_callback'] = true;
if (method_exists($this->event_handler_instance, 'onStart')) { if (\method_exists($this->event_handler_instance, 'onStart')) {
Tools::callFork($this->event_handler_instance->onStart()); Tools::callFork($this->event_handler_instance->onStart());
} }
if ($this->inited()) { if ($this->inited()) {

View File

@ -16,11 +16,13 @@
* *
* @link https://docs.madelineproto.xyz MadelineProto documentation * @link https://docs.madelineproto.xyz MadelineProto documentation
*/ */
namespace danog\MadelineProto\Wrappers; namespace danog\MadelineProto\Wrappers;
use Amp\Promise; use Amp\Promise;
use danog\MadelineProto\Shutdown; use danog\MadelineProto\Shutdown;
use danog\MadelineProto\Tools; use danog\MadelineProto\Tools;
/** /**
* Manages logging in and out. * Manages logging in and out.
*/ */
@ -40,7 +42,7 @@ trait Loop
* *
* @return mixed * @return mixed
*/ */
public function loop($callback = null) : \Generator public function loop($callback = null): \Generator
{ {
if (\is_callable($callback)) { if (\is_callable($callback)) {
$this->logger->logger('Running async callable'); $this->logger->logger('Running async callable');
@ -114,7 +116,7 @@ trait Loop
$this->logger->logger("Added unlock callback with id $id!"); $this->logger->logger("Added unlock callback with id $id!");
if ($needs_restart) { if ($needs_restart) {
$this->logger->logger("Adding restart callback!"); $this->logger->logger("Adding restart callback!");
$id = Shutdown::addCallback(static function () use(&$logger) { $id = Shutdown::addCallback(static function () use (&$logger) {
$address = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'tls' : 'tcp') . '://' . $_SERVER['SERVER_NAME']; $address = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'tls' : 'tcp') . '://' . $_SERVER['SERVER_NAME'];
$port = $_SERVER['SERVER_PORT']; $port = $_SERVER['SERVER_PORT'];
$uri = $_SERVER['REQUEST_URI']; $uri = $_SERVER['REQUEST_URI'];
@ -191,7 +193,7 @@ trait Loop
* *
* @return Promise * @return Promise
*/ */
public function loopFork() : Promise public function loopFork(): Promise
{ {
return Tools::callFork($this->loop()); return Tools::callFork($this->loop());
} }

View File

@ -42,7 +42,7 @@ class FileIdTest extends TestCase
} }
/** /**
* Teardown * Teardown.
* *
* @return void * @return void
*/ */