From 81f8bc60535659354707161cac0e92eca1af183c Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sat, 19 Jun 2021 13:38:15 -0500 Subject: [PATCH 1/2] Add location tracking --- happybot/weather.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/happybot/weather.sh b/happybot/weather.sh index 7fc40f5..819a5fd 100644 --- a/happybot/weather.sh +++ b/happybot/weather.sh @@ -9,9 +9,20 @@ irc | while read -r n m; do place="$(m 1)" elif hreg '^#(?:temp|temperature|weather) (.*)$' "$m"; then place="$(m 1)" + elif hreg '^#at (.*)$' "$m" + place="$(m 1)" + if grep -q "^$n," places.csv; then + sed 's|^'"$n"',.*|'"$n,$place"'|' > places-new.csv + mv -f places-new.csv places.csv + else + printf '%s,%s' "$n" "$place" >> places.csv + fi else continue; fi + if [ -z "$1" ]; then + place=$(awk -F, -v "n=$n" '$1==n{print $2}' places.csv) + fi plason="$(curl -s -g -G --data-urlencode "q=$place" --data-urlencode 'format=json' 'https://nominatim.openstreetmap.org/search')" if [ "x$plason" == "x[]" ]; then answer="Could not find location: $place" -- 2.45.1 From 23d2f78be879ffd55f57f3865c0095c5e2c15dd1 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sat, 19 Jun 2021 13:39:53 -0500 Subject: [PATCH 2/2] Have happybot ignore the weather lookup with #at --- happybot/weather.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/happybot/weather.sh b/happybot/weather.sh index 819a5fd..9d23065 100644 --- a/happybot/weather.sh +++ b/happybot/weather.sh @@ -17,6 +17,8 @@ irc | while read -r n m; do else printf '%s,%s' "$n" "$place" >> places.csv fi + + continue else continue; fi -- 2.45.1