From b5c79e3f77fda034b7c0ad485f07b1e3c92d7533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 4 Oct 2022 11:34:40 +0200 Subject: reaktor2: add krebsfood hook --- krebs/2configs/reaktor2.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'krebs/2configs') diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index f5041a59d..9d738813b 100644 --- a/krebs/2configs/reaktor2.nix +++ b/krebs/2configs/reaktor2.nix @@ -75,6 +75,30 @@ let ''; }; } + { + pattern = "18@p"; + activate = "match"; + command = { + env.radius = toString 250; # metres around c-base to search + filename = pkgs.writeDash "krebsfood" '' + set -efu + expected_max_results=1024 # the upper bound on the number of restaurants + + echo '[out:json];node(id:260050809)->.cbase; + ( + node(around.cbase:'$radius')[amenity=fast_food]; + node(around.cbase:'$radius')[amenity=restaurant]; + );out;' \ + | ${pkgs.curl}/bin/curl -sSL -d @- -X POST http://overpass-api.de/api/interpreter \ + | ${pkgs.jq}/bin/jq -r --argjson random "$(shuf -i 0-$expected_max_results -n 1)" ' + .elements + | length as $length + | .[$random % $length] + | "How about \(.tags.name) (https://www.openstreetmap.org/\(.type)/\(.id))?" + ' + ''; + }; + } { pattern = ''^([\H-]*?):?\s+([+-][1-9][0-9]*)\s+(\S+)$''; activate = "match"; -- cgit v1.2.3