Add annna cooking advice service. - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit 50a4c26037d0d41c9d9a6e901f8c374ce66400b6 | |
parent e403db19eb13cece6af7b47fc0775ae5eca2787e | |
Author: Annna Robert-Houdin <[email protected]> | |
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(-) | |
--- | |
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 "$… | |
+ ;; | |
+ 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: ${p… | |
+ else | |
+ annna-say -c "${channel}" "${user}, I could not find any recip… | |
+ 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 | |
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]*\).… | |
+ |