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
|
* 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!
|
* 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');
|
$currentYear = date('Y');
|
||||||
$dateRange = sprintf('%s0101-%s1231', $currentYear, $currentYear);
|
$dateRange = sprintf('%s0101-%s1231', $currentYear, $currentYear);
|
||||||
|
|
||||||
$key = 'e21758b9c711463552fb9c70ac7d4273';
|
$key = 'e21758b9c711463552fb9c70ac7d4273';
|
||||||
$kommune = 2601;
|
|
||||||
$strasse = 2146;
|
$home = getenv('HOME');
|
||||||
$tgReceiverId = 0; // Positive values are users, negative values are group IDs
|
$configFilePath = sprintf('%s/.muell.yaml', $home);
|
||||||
$pathToBot = '~/bin/YMBot';
|
|
||||||
|
// 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);
|
$url = sprintf('https://api.abfall.io/?key=%s&modus=d6c5855a62cf32a4dadbc2831f0f295f&waction=export_csv', $key);
|
||||||
|
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'f_id_kommune' => $kommune,
|
'f_id_kommune' => $config['kommune'],
|
||||||
'f_id_strasse' => $strasse,
|
'f_id_strasse' => $config['strasse'],
|
||||||
'f_id_abfalltyp_0' => 50,
|
'f_id_abfalltyp_0' => 50,
|
||||||
'f_id_abfalltyp_1' => 161,
|
'f_id_abfalltyp_1' => 161,
|
||||||
'f_id_abfalltyp_2' => 53,
|
'f_id_abfalltyp_2' => 53,
|
||||||
@ -71,7 +84,7 @@ if ($response !== false) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($what !== '') {
|
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