Improved recipe search and results - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit fda3c41881dbea823ab82a10f69ff569794e41c6 DIR parent 221c0f28a1d48b22fca699d611750647b5f23f91 HTML Author: Scarlett McAllister <no+reply@roygbyte.com> Date: Tue, 26 Mar 2024 20:39:37 -0300 Improved recipe search and results Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: M annna-message-common | 2 +- M fridge-recipe-search | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -499,7 +499,7 @@ case "${text}" in results="$(fridge-recipe-search "${ingredients}")" if [ -n "${results}" ]; then - puri="$(printf "%s\n" "${results}" | bitreich-paste)" + puri="$(printf "%s\n" "${results}" | bitreich-paste | sed 's,/0/,/1/,')" annna-say -s "${server}" -c "${channel}" "${user}, here are some recipes: ${puri}" else annna-say -s "${server}" -c "${channel}" "${user}, I could not find any recipes for you." DIR diff --git a/fridge-recipe-search b/fridge-recipe-search @@ -7,8 +7,20 @@ then fi ingredients="$@" -printf "/recipes?%s\r\n" "${ingredients}" \ + +# A note about the awk script below. I chose to hardcode the port, 70, +# because I couldn't figure out how to remove what I think is null +# character at the end of each line. This bastard of char was causing the +# ']' to be shown on the next line. +moar=$(printf "/~bencollver/recipes/search?%s\r\n" "${ingredients}" \ + | nc tilde.pink 70 \ + | grep "^0" \ + | sed 's,^0,,' \ + | awk -F '\t' '{ printf "[0|%s|%s|%s|%s]\n", $1, $2, $3, 70; }') +adc=$(printf "/recipes?%s\r\n" "${ingredients}" \ | nc adamsgaard.dk 70 \ | grep "^0" \ - | sed 's,\r$,,; s,\(.\)\([^\t]*\)\t\([^\t]*\)\t\([^\t]*\)\t\([^\t]*\).*,gopher://\4:\5/\1\3 ( \2 ),; s,:70/,/,;' - + | sed 's,^0,,' \ + | awk -F '\t' '{ printf "[0|%s|%s|%s|%s]\n", $1, $2, $3, 70; }') +all=$( printf "%s\n%s" "$moar" "$adc" | sort ) +printf "%s" "$all"