summaryrefslogtreecommitdiffstats
path: root/krebs/2configs
diff options
context:
space:
mode:
authorKierĂ¡n Meinhardt <kmein@posteo.de>2022-10-04 11:34:40 +0200
committerlassulus <lassulus@lassul.us>2022-10-04 11:45:35 +0200
commitb5c79e3f77fda034b7c0ad485f07b1e3c92d7533 (patch)
treed04d93ce8836a3af3112eefe1f2c162b316bbbd8 /krebs/2configs
parent8f929b04b3de012a9c72306786f076b78aa9f98c (diff)
reaktor2: add krebsfood hook
Diffstat (limited to 'krebs/2configs')
-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];