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);
|
$jd = (float) str_replace(',', '.', $jdText);
|
||||||
$observedAtUtc = jdToUtcString($jd);
|
$observedAtUtc = jdToUtcString($jd);
|
||||||
|
|
||||||
@@ -635,8 +640,8 @@ function parseWebObsPage(string $html): array
|
|||||||
'jd' => number_format($jd, 6, '.', ''),
|
'jd' => number_format($jd, 6, '.', ''),
|
||||||
'observed_at_utc' => $observedAtUtc,
|
'observed_at_utc' => $observedAtUtc,
|
||||||
'calendar_date_text' => $calendarDateText !== '' ? $calendarDateText : null,
|
'calendar_date_text' => $calendarDateText !== '' ? $calendarDateText : null,
|
||||||
'magnitude' => normalizeNumeric($magnitudeText),
|
'magnitude' => $magnitude,
|
||||||
'magnitude_error' => $magnitudeErrorText !== '' ? normalizeNumeric($magnitudeErrorText) : null,
|
'magnitude_error' => $magnitudeErrorText !== '' ? parseStrictDecimal($magnitudeErrorText) : null,
|
||||||
'filter_code' => $filterCode !== '' ? $filterCode : null,
|
'filter_code' => $filterCode !== '' ? $filterCode : null,
|
||||||
'observer_code' => $observerCode !== '' ? $observerCode : null,
|
'observer_code' => $observerCode !== '' ? $observerCode : null,
|
||||||
'notes_raw' => $notesRaw,
|
'notes_raw' => $notesRaw,
|
||||||
@@ -662,6 +667,20 @@ function normalizeNumeric(string $value): string
|
|||||||
return str_replace(',', '.', trim($value));
|
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
|
function jdToUtcString(float $jd): string
|
||||||
{
|
{
|
||||||
$jd += 0.5;
|
$jd += 0.5;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ function buildTcrbLatestVMessage(array $observation, DateTimeImmutable $nowBerli
|
|||||||
$observedText = formatGermanDateTime($observedUtc);
|
$observedText = formatGermanDateTime($observedUtc);
|
||||||
$magnitude = formatDecimal($observation['magnitude'] ?? null, 3);
|
$magnitude = formatDecimal($observation['magnitude'] ?? null, 3);
|
||||||
$magnitudeError = $observation['magnitude_error'] !== null
|
$magnitudeError = $observation['magnitude_error'] !== null
|
||||||
? ' ± ' . formatDecimal($observation['magnitude_error'], 3)
|
? ' ± ' . formatDecimal($observation['magnitude_error'], 3)
|
||||||
: '';
|
: '';
|
||||||
$jd = formatDecimal($observation['jd'] ?? null, 6);
|
$jd = formatDecimal($observation['jd'] ?? null, 6);
|
||||||
$observerCode = trim((string) ($observation['observer_code'] ?? ''));
|
$observerCode = trim((string) ($observation['observer_code'] ?? ''));
|
||||||
@@ -120,7 +120,7 @@ function buildTcrbLatestVMessage(array $observation, DateTimeImmutable $nowBerli
|
|||||||
'Magnitude: ' . $magnitude . $magnitudeError,
|
'Magnitude: ' . $magnitude . $magnitudeError,
|
||||||
'Zeitpunkt: ' . $observedText,
|
'Zeitpunkt: ' . $observedText,
|
||||||
'JD: ' . $jd,
|
'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.
|
* 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
|
function telegramHttpPostMultipart(string $url, array $fields, string $fileField, string $filePath, ?string $fileName = null): array
|
||||||
|
|||||||
Reference in New Issue
Block a user