Using yaml config file
This commit is contained in:
parent
14299072d5
commit
baaa2990da
@ -7,26 +7,39 @@
|
||||
*
|
||||
* Die Angaben hier im Skript stehen für Hörstel als Kommune und Im Wiesengrund als Strasse
|
||||
*
|
||||
* Um die Daten an Telegram zu senden, musst du dir ein Skript/Progtramm schreiben, dass die API
|
||||
* Um die Daten an Telegram zu senden, musst du dir ein Skript/Programm schreiben, dass die API
|
||||
* von Telegram verwendet und Daten an dich oder deine Gruppe senden kann!
|
||||
*
|
||||
* Beispiel für eine Konfigurationsdatei:
|
||||
* tgReceiver: <hier die ID der Gruppe/ des Teilnhemers eintragen>
|
||||
* kommune: 2601
|
||||
* strasse: 2146
|
||||
* pathBot: '~/bin/YMBot'
|
||||
*/
|
||||
|
||||
$currentYear = date('Y');
|
||||
$dateRange = sprintf('%s0101-%s1231', $currentYear, $currentYear);
|
||||
|
||||
$key = 'e21758b9c711463552fb9c70ac7d4273';
|
||||
$kommune = 2601;
|
||||
$strasse = 2146;
|
||||
$tgReceiverId = 0; // Positive values are users, negative values are group IDs
|
||||
$pathToBot = '~/bin/YMBot';
|
||||
|
||||
$home = getenv('HOME');
|
||||
$configFilePath = sprintf('%s/.muell.yaml', $home);
|
||||
|
||||
// Read the config file if existing
|
||||
if (!file_exists($configFilePath)) {
|
||||
echo "Bitte .muell.yaml im Homeverzeichnis anlegen!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
$config = yaml_parse_file($configFilePath);
|
||||
|
||||
$url = sprintf('https://api.abfall.io/?key=%s&modus=d6c5855a62cf32a4dadbc2831f0f295f&waction=export_csv', $key);
|
||||
|
||||
$ch = curl_init($url);
|
||||
|
||||
$data = [
|
||||
'f_id_kommune' => $kommune,
|
||||
'f_id_strasse' => $strasse,
|
||||
'f_id_kommune' => $config['kommune'],
|
||||
'f_id_strasse' => $config['strasse'],
|
||||
'f_id_abfalltyp_0' => 50,
|
||||
'f_id_abfalltyp_1' => 161,
|
||||
'f_id_abfalltyp_2' => 53,
|
||||
@ -71,7 +84,7 @@ if ($response !== false) {
|
||||
break;
|
||||
}
|
||||
if ($what !== '') {
|
||||
shell_exec(sprintf("echo Morgen %s abgeholt | %s -u %d", $what, $pathToBot, $tgReceiverId));
|
||||
shell_exec(sprintf("echo Morgen %s abgeholt | %s -u %d", $what, $config['pathBot'], $config['tgReceiver']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user