Telegram repariert.
This commit is contained in:
@@ -626,6 +626,11 @@ function parseWebObsPage(string $html): array
|
||||
}
|
||||
}
|
||||
|
||||
$magnitude = parseStrictDecimal($magnitudeText);
|
||||
if ($magnitude === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$jd = (float) str_replace(',', '.', $jdText);
|
||||
$observedAtUtc = jdToUtcString($jd);
|
||||
|
||||
@@ -635,8 +640,8 @@ function parseWebObsPage(string $html): array
|
||||
'jd' => number_format($jd, 6, '.', ''),
|
||||
'observed_at_utc' => $observedAtUtc,
|
||||
'calendar_date_text' => $calendarDateText !== '' ? $calendarDateText : null,
|
||||
'magnitude' => normalizeNumeric($magnitudeText),
|
||||
'magnitude_error' => $magnitudeErrorText !== '' ? normalizeNumeric($magnitudeErrorText) : null,
|
||||
'magnitude' => $magnitude,
|
||||
'magnitude_error' => $magnitudeErrorText !== '' ? parseStrictDecimal($magnitudeErrorText) : null,
|
||||
'filter_code' => $filterCode !== '' ? $filterCode : null,
|
||||
'observer_code' => $observerCode !== '' ? $observerCode : null,
|
||||
'notes_raw' => $notesRaw,
|
||||
@@ -662,6 +667,20 @@ function normalizeNumeric(string $value): string
|
||||
return str_replace(',', '.', trim($value));
|
||||
}
|
||||
|
||||
function parseStrictDecimal(string $value): ?string
|
||||
{
|
||||
$normalized = normalizeNumeric($value);
|
||||
if ($normalized === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/^[+-]?\d+(?:\.\d+)?$/', $normalized) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
function jdToUtcString(float $jd): string
|
||||
{
|
||||
$jd += 0.5;
|
||||
|
||||
@@ -108,7 +108,7 @@ function buildTcrbLatestVMessage(array $observation, DateTimeImmutable $nowBerli
|
||||
$observedText = formatGermanDateTime($observedUtc);
|
||||
$magnitude = formatDecimal($observation['magnitude'] ?? null, 3);
|
||||
$magnitudeError = $observation['magnitude_error'] !== null
|
||||
? ' ± ' . formatDecimal($observation['magnitude_error'], 3)
|
||||
? ' ± ' . formatDecimal($observation['magnitude_error'], 3)
|
||||
: '';
|
||||
$jd = formatDecimal($observation['jd'] ?? null, 6);
|
||||
$observerCode = trim((string) ($observation['observer_code'] ?? ''));
|
||||
@@ -120,7 +120,7 @@ function buildTcrbLatestVMessage(array $observation, DateTimeImmutable $nowBerli
|
||||
'Magnitude: ' . $magnitude . $magnitudeError,
|
||||
'Zeitpunkt: ' . $observedText,
|
||||
'JD: ' . $jd,
|
||||
'Nächster möglicher Ausbruch: '. $nextPossibleEruptionDate,
|
||||
'Nächster möglicher Ausbruch: ' . $nextPossibleEruptionDate,
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
* und Dokumenten. Die Cron-Tasks muessen dadurch keine Request-Details kennen.
|
||||
*/
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/public/telegram/lib/http.php';
|
||||
require_once dirname(__DIR__, 3) . '/public/telegram/lib/http.php';
|
||||
|
||||
|
||||
function telegramHttpPostMultipart(string $url, array $fields, string $fileField, string $filePath, ?string $fileName = null): array
|
||||
|
||||
Reference in New Issue
Block a user