reaktor2: add krebsfood hook

This commit is contained in:
Kierán Meinhardt 2022-10-04 11:34:40 +02:00 committed by lassulus
parent 8f929b04b3
commit b5c79e3f77

View File

@ -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";