Add annna cooking advice service. - annna - Annna the nice friendly bot.
(HTM) git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
---
(DIR) commit 50a4c26037d0d41c9d9a6e901f8c374ce66400b6
(DIR) parent e403db19eb13cece6af7b47fc0775ae5eca2787e
(HTM) Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Fri, 27 Aug 2021 16:05:04 +0200
Add annna cooking advice service.
Diffstat:
M annna-message-common | 18 +++++++++++++++++-
A fridge-recipe-search | 14 ++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/annna-message-common b/annna-message-common
@@ -363,6 +363,23 @@ case "${text}" in
suri="$(printf "%s\n" "${word}" | bitreich-speak)"
annna-say -c "${channel}" "${suri}"
;;
+"${botname}, what can I cook with "*)
+ ingredients="$(printf "%s\n" "${text}" | cut -c 29- | sed 's,\t, ,g')"
+ case "$word" in
+ *\?)
+ word="$(printf "%s\n" "${word}" | cut -c -"$(($(expr length "${word}") - 1))")"
+ ;;
+ esac
+
+ results="$(fridge-recipe-search "${ingredients}")"
+ if [ -n "${results}" ];
+ then
+ puri="$(printf "%s\n" "${results}" | bitreich-paste)"
+ annna-say -c "${channel}" "${user}, here are some recipes: ${puri}"
+ else
+ annna-say -c "${channel}" "${user}, I could not find any recipes for you."
+ fi
+ ;;
"${botname}, wolfram is "*)
word="$(printf "%s\n" "${text}" | cut -c 19- | sed 's,\t, ,g')"
case "$word" in
@@ -380,7 +397,6 @@ case "${text}" in
| tail -n +2 \
| sed 's,i\(.*\)fake\texample.com.*,\1,;s,[ \t]*$,,')"
-
if [ -n "$dresult" ];
then
case "${dresult}" in
(DIR) diff --git a/fridge-recipe-search b/fridge-recipe-search
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ $# -lt 1 ];
+then
+ printf "usage: %s ingredient\n" "$(basename "$0")" >&2
+ exit 1
+fi
+
+ingredients="$@"
+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\3 ( \2 ),; s,:70/,/,;'
+