Add some error handling to weather. - 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 d7431c63770a238bf812722b145c1b5841377229 DIR parent 7ab66a57767d5d4a52b3b3cbe5533983691fd6d1 HTML Author: eidolon <me@nou.meme> Date: Sun, 27 Aug 2023 15:41:08 -0400 Add some error handling to weather. Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: M annna-message-common | 5 +++-- M weather | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -570,10 +570,11 @@ case "${text}" in weatherplace="$(printf "%s\n" "${text}" \ | sed 's,.*weather at \(.*\),\1,' \ | tr -d '?')" - weathertext="$(weather "${weatherplace}")" - if [ -n "${weathertext}" ]; + if weathertext="$(weather "${weatherplace}")" then annna-say -s "${server}" -c "${channel}" "${user}, the weather at ${weatherplace} is ${weathertext}" + else + annna-say -s "${server}" -c "${channel}" "${user}, there is no weather at ${weatherplace}." fi } & ;; DIR diff --git a/weather b/weather @@ -2,7 +2,7 @@ [ -z "$1" ] && { printf 'usage: %s <location>\n' "${0##*/}" >&2 - exit + exit 1 } location=$(printf %s "$1" | sed 's, ,\%20,g')