summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/reaktor2.nix
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/2configs/reaktor2.nix')
-rw-r--r--krebs/2configs/reaktor2.nix24
1 files changed, 24 insertions, 0 deletions
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
@@ -76,6 +76,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";
arguments = [1 2 3];