diff --git a/happybot/weather.sh b/happybot/weather.sh index 7fc40f5..9d23065 100644 --- a/happybot/weather.sh +++ b/happybot/weather.sh @@ -9,9 +9,22 @@ 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 + + continue 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"