change weather api
This commit is contained in:
parent
6a0ee2ac53
commit
b5cc10a0cc
34
start.sh
34
start.sh
@ -162,10 +162,34 @@ usage() {
|
|||||||
|
|
||||||
# $1 loc
|
# $1 loc
|
||||||
weather() {
|
weather() {
|
||||||
l=$1
|
param=$1
|
||||||
[ -z "$l" ] \
|
|
||||||
&& l=heidelberg
|
[ -z $param ] \
|
||||||
say "$(curl -s "https://wttr.in/$l?lang=de&format=%l:+%t+%C+%w+%h+Regen")"
|
&& param=Heidelberg,DE
|
||||||
|
|
||||||
|
echo "$param" | fgrep -q "," \
|
||||||
|
|| param="$param,DE"
|
||||||
|
|
||||||
|
|
||||||
|
DATA=$(curl -s "https://api.openweathermap.org/data/2.5/weather?q=$param&lang=de&units=metric&appid=a4c6e6d6beba2ff733ed81b7e2cac530")
|
||||||
|
#DATA=$(cat test.json)
|
||||||
|
|
||||||
|
RESPONSE=$(echo "$DATA" \
|
||||||
|
| jq -rc '.name,[.main.temp, .weather[].description][], .main.humidity, .wind.speed' 2> /dev/null \
|
||||||
|
| awk ' \
|
||||||
|
NR == 1 { printf("Wetter in %s: ", $0) } \
|
||||||
|
NR == 2 { printf("%.0d°C, ", $0) } \
|
||||||
|
NR == 3 { printf("%s", $0) } \
|
||||||
|
NR == 4 { printf(" (%d%%), ", $0) } \
|
||||||
|
NR == 5 { printf("Wind: %.0dkm/h", $0) } \
|
||||||
|
')
|
||||||
|
|
||||||
|
case "$RESPONSE" in
|
||||||
|
*null:*) RESPONSE="$param konnte nicht gefunden werden. Usage: !wetter <stadt>[,<länderkürzel>]"
|
||||||
|
esac
|
||||||
|
|
||||||
|
say "$RESPONSE"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,7 +249,7 @@ do
|
|||||||
# character set for safety reasons.
|
# character set for safety reasons.
|
||||||
ARG=$(echo "$line" \
|
ARG=$(echo "$line" \
|
||||||
| tr '[:upper:]' '[:lower:]' \
|
| tr '[:upper:]' '[:lower:]' \
|
||||||
| sed -n 's|.*![a-z]* \([a-zA-Z0-9\-_+]*\).*|\1|p')
|
| sed -n 's|.*![a-z]* \([a-zA-Z0-9,\-_+]*\).*|\1|p')
|
||||||
|
|
||||||
# We call it gummipunkte now.
|
# We call it gummipunkte now.
|
||||||
KARMA=$(echo "$line" \
|
KARMA=$(echo "$line" \
|
||||||
|
Loading…
Reference in New Issue
Block a user