Skip to content

Commit

Permalink
Call the fallback and the conversation handler also for other types o…
Browse files Browse the repository at this point in the history
…f media
  • Loading branch information
sergix44 committed Dec 27, 2020
1 parent c22f565 commit 5ed2eb8
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/Zanzara/Listener/ListenerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,41 @@ public function resolveListeners(Update $update): PromiseInterface

case Message::class:
$text = $update->getMessage()->getText();
if ($text) {
$chatId = $update->getEffectiveChat()->getId();
$this->conversationManager->getConversationHandler($chatId)
->then(function ($handlerInfo) use ($chatId, $text, $deferred, &$listeners) {
if (!$handlerInfo) {
$chatId = $update->getEffectiveChat()->getId();
$this->conversationManager->getConversationHandler($chatId)
->then(function ($handlerInfo) use ($chatId, $text, $deferred, &$listeners) {
if (!$handlerInfo) {
if ($text) {
$this->findListenerAndPush($listeners, 'messages', $text);
$deferred->resolve($listeners);
return;
} elseif ($this->fallbackListener) {
$listeners[] = $this->fallbackListener;
}
$deferred->resolve($listeners);
return;
}

$skipListeners = $handlerInfo[1];

$skipListeners = $handlerInfo[1];
if ($skipListeners) {
if (!$skipListeners && $text) {
$listener = $this->findListenerAndPush($listeners, 'messages', $text);
if (!$listener) {
$listeners[] = new Listener($handlerInfo[0], $this->container);
} else {
$listener = $this->findListenerAndPush($listeners, 'messages', $text);
if (!$listener) {
$listeners[] = new Listener($handlerInfo[0], $this->container);
} else {
$this->conversationManager->deleteConversationCache($chatId);
}
$this->conversationManager->deleteConversationCache($chatId);
}

$deferred->resolve($listeners);
})->otherwise(function ($e) use ($deferred) {
// if something goes wrong, reject the promise
$deferred->reject($e);
});

} else {
$deferred->resolve($listeners);
}
} else {
$listeners[] = new Listener($handlerInfo[0], $this->container);
}

$deferred->resolve($listeners);
})->otherwise(function ($e) use ($deferred) {
// if something goes wrong, reject the promise
$deferred->reject($e);
});
break;

default:
$deferred->resolve($listeners);

}

return $deferred->promise();
Expand Down

0 comments on commit 5ed2eb8

Please sign in to comment.