summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKierĂ¡n Meinhardt <kmein@posteo.de>2022-10-19 09:16:30 +0200
committerlassulus <lassulus@lassul.us>2022-11-17 12:23:28 +0100
commit18adbab5ed2ba7f0bd0bc75e1e82d16ed33e7ab1 (patch)
treea9b2c7f789249628d8c43e682b59f2cecf4b4449
parent17fc13592935fc7c8119e24980ea3a83f9773043 (diff)
reaktor2 krebsfood: support poi and radius
-rw-r--r--krebs/2configs/reaktor2.nix16
1 files changed, 12 insertions, 4 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 41cfd7735..3dc3ce0a9 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -185,8 +185,9 @@ let
};
}
{
- pattern = "18@p";
+ pattern = ''^18@p\s+(\S+)\s+(\d+)m$'';
activate = "match";
+ arguments = [1 2];
command = {
env = {
CACHE_DIR = "${stateDir}/krebsfood";
@@ -202,9 +203,16 @@ let
osm-restaurants = pkgs.callPackage "${osm-restaurants-src}/osm-restaurants" {};
in pkgs.writeDash "krebsfood" ''
set -efu
- ecke_lat=52.51252
- ecke_lon=13.41740
- ${osm-restaurants}/bin/osm-restaurants --radius 500 --latitude "$ecke_lat" --longitude "$ecke_lon" \
+ poi=$(curl -fsS http://c.r/poi.json | jq --arg name "$1" '.[$name]')
+ if [ "$poi" = null ]; then
+ latitude=52.51252
+ longitude=13.41740
+ else
+ latitude=$(echo "$poi" | jq -r .latitude)
+ longitude=$(echo "$poi" | jq -r .longitude)
+ fi
+
+ ${osm-restaurants}/bin/osm-restaurants --radius "$2" --latitude "$latitude" --longitude "$longitude" \
| ${pkgs.jq}/bin/jq -r '"How about \(.tags.name) (https://www.openstreetmap.org/\(.type)/\(.id)), open \(.tags.opening_hours)?"'
'
'';