/**
 * @return Generator
 * @throws \Steelbot\TelegramBotApi\Exception\TelegramBotApiException
 */
function botCoroutine() : \Generator
{
    $api = new Api(getenv('BOT_TOKEN'));
    $updateId = 1;
    printf("Waiting for updates ...\n");
    while (true) {
        // waiting for updates from telegram server
        /** @var Update[] $updates */
        $updates = (yield from $api->getUpdates($updateId));
        foreach ($updates as $update) {
            $method = processUpdate($update);
            if (is_object($method)) {
                yield from $api->execute($method);
            }
            $updateId = $update->updateId;
        }
    }
}
$coroutine = new Coroutine(botCoroutine());
$coroutine->done(null, function (\Throwable $exception) {
    echo "Exception catched:\n";
    echo "    Code: {$exception->getCode()}\n";
    echo "    Message: {$exception->getMessage()}\n";
    echo "    File: {$exception->getFile()}\n";
    echo "    Line: {$exception->getLine()}\n";
});
Loop\run();