diff --git a/src/danog/MadelineProto/Loop/Update/FeedLoop.php b/src/danog/MadelineProto/Loop/Update/FeedLoop.php index 169ec16c..76c2db04 100644 --- a/src/danog/MadelineProto/Loop/Update/FeedLoop.php +++ b/src/danog/MadelineProto/Loop/Update/FeedLoop.php @@ -172,7 +172,7 @@ class FeedLoop extends ResumableSignalLoop switch ($update['_']) { case 'updateNewChannelMessage': case 'updateEditChannelMessage': - $channelId = $update['message']['to_id']['channel_id']; + $channelId = isset($update['message']['to_id']['channel_id']) ? $update['message']['to_id']['channel_id'] : false; break; case 'updateChannelWebPage': case 'updateDeleteChannelMessages': @@ -207,12 +207,13 @@ class FeedLoop extends ResumableSignalLoop $from = false; $via_bot = false; $entities = false; - if (($from = isset($update['message']['from_id']) && !yield $this->API->peer_isset_async($update['message']['from_id'])) || + if ($update['message']['_'] !== 'messageEmpty' && ( + ($from = isset($update['message']['from_id']) && !yield $this->API->peer_isset_async($update['message']['from_id'])) || ($to = !yield $this->API->peer_isset_async($update['message']['to_id'])) || ($via_bot = isset($update['message']['via_bot_id']) && !yield $this->API->peer_isset_async($update['message']['via_bot_id'])) || ($entities = isset($update['message']['entities']) && !yield $this->API->entities_peer_isset_async($update['message']['entities'])) // || //isset($update['message']['fwd_from']) && !yield $this->fwd_peer_isset_async($update['message']['fwd_from']) - ) { + )) { $log = ''; if ($from) { $log .= "from_id {$update['message']['from_id']}, "; diff --git a/src/danog/MadelineProto/Loop/Update/UpdateLoop.php b/src/danog/MadelineProto/Loop/Update/UpdateLoop.php index 8c00b25d..01637d8f 100644 --- a/src/danog/MadelineProto/Loop/Update/UpdateLoop.php +++ b/src/danog/MadelineProto/Loop/Update/UpdateLoop.php @@ -48,7 +48,7 @@ class UpdateLoop extends ResumableSignalLoop while (!$this->API->settings['updates']['handle_updates'] || !$this->has_all_auth()) { if (yield $this->waitSignal($this->pause())) { - $API->logger->logger("Exiting $this"); + $API->logger->logger("Exiting $this due to signal"); $this->exitedLoop(); return; @@ -64,7 +64,7 @@ class UpdateLoop extends ResumableSignalLoop while (true) { while (!$this->API->settings['updates']['handle_updates'] || !$this->has_all_auth()) { if (yield $this->waitSignal($this->pause())) { - $API->logger->logger("Exiting $this"); + $API->logger->logger("Exiting $this due to signal"); $this->exitedLoop(); return; @@ -89,7 +89,7 @@ class UpdateLoop extends ResumableSignalLoop } catch (RPCErrorException $e) { if (in_array($e->rpc, ['CHANNEL_PRIVATE', 'CHAT_FORBIDDEN'])) { $feeder->signal(true); - $API->logger->logger("Exiting $this"); + $API->logger->logger("Channel private, exiting $this"); $this->exitedLoop(); return true; } @@ -182,7 +182,7 @@ class UpdateLoop extends ResumableSignalLoop $this->API->signalUpdate(); if (yield $this->waitSignal($this->pause($timeout))) { - $API->logger->logger("Exiting $this"); + $API->logger->logger("Exiting $this due to signal"); $this->exitedLoop(); return; diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 1b4635d1..95ab32aa 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -217,6 +217,7 @@ class MTProto extends AsyncConstruct implements TLCallback } } yield $this->get_config_async([], ['datacenter' => $this->datacenter->curdc]); + $this->startUpdateSystem(); $this->v = self::V; } @@ -419,6 +420,7 @@ class MTProto extends AsyncConstruct implements TLCallback yield $this->get_cdn_config_async($this->datacenter->curdc); $this->setup_logger(); } + $this->startUpdateSystem(); if ($this->authorized === self::LOGGED_IN && !$this->authorization['user']['bot'] && $this->settings['peer']['cache_all_peers_on_startup']) { yield $this->get_dialogs_async($force); } @@ -874,7 +876,12 @@ class MTProto extends AsyncConstruct implements TLCallback } yield $this->get_phone_config_async(); - + } + public function startUpdateSystem() + { + if (!isset($this->seqUpdater)) { + $this->seqUpdater = new SeqLoop($this); + } foreach ($this->channels_state->get() as $state) { $channelId = $state->getChannel(); if (!isset($this->feeders[$channelId])) { @@ -888,7 +895,6 @@ class MTProto extends AsyncConstruct implements TLCallback } $this->seqUpdater->start(); } - public function get_phone_config_async($watcherId = null) { if ($this->authorized === self::LOGGED_IN && class_exists('\\danog\\MadelineProto\\VoIPServerConfigInternal') && !$this->authorization['user']['bot'] && $this->datacenter->sockets[$this->settings['connection_settings']['default_dc']]->temp_auth_key !== null) {