38 lines
809 B
PHP
38 lines
809 B
PHP
|
#!/usr/bin/php7.1
|
||
|
<?php
|
||
|
|
||
|
require __DIR__.'/base/block.php';
|
||
|
|
||
|
$url = 'https://fr.wttr.in/?format=%l+%c+%t+%m';
|
||
|
|
||
|
$command = sprintf('curl %s', escapeshellarg($url));
|
||
|
$output = trim(shell_exec($command));
|
||
|
|
||
|
if (!empty($output)) {
|
||
|
if (preg_match('/Unknow location/', $output)) {
|
||
|
$output = 'Météo HS';
|
||
|
}
|
||
|
|
||
|
if (preg_match('/mesure de faire de nouvelles/', $output)) {
|
||
|
$output = 'Météo HS';
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
$city = explode(', ', $output)[0];
|
||
|
|
||
|
echo block(
|
||
|
'meteo',
|
||
|
[
|
||
|
'full_text' => pspan($output, '#fff'),
|
||
|
]
|
||
|
);
|
||
|
} catch(\Exception $e) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (getenv('BLOCK_BUTTON') === '1') {
|
||
|
$url = 'https://fr.wttr.in/';
|
||
|
$command = sprintf('xdg-open %s', escapeshellarg($url));
|
||
|
shell_exec($command);
|
||
|
}
|