Handle empty messages properly

This commit is contained in:
Daniil Gentili 2019-06-01 13:42:17 +00:00
parent 2924bb66a1
commit 94f2de3cd2
3 changed files with 16 additions and 9 deletions

View File

@ -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']}, ";

View File

@ -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;

View File

@ -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) {