Add new plugin : wttr

Based on an old script by meh : https://github.com/jusdepatate/wttr.sh
pull/1324/head
Jus de Patate 2019-02-04 14:05:19 +01:00 committed by GitHub
parent 71ee7083cf
commit 997dfdd04e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
function wttr() {
if [ -n "$1" ]; then
if [ "$(ping -c 1 wttr.in)" ]; then
if [ "$(which curl 2>/dev/null)" ]; then
CITY="$(curl -s ipinfo.io/city)"
echo "Weather of $1"
echo " "
curl -s "wttr.in/$1?Q0"
elif [ "$(which wget 2>/dev/null)" ]; then
CITY="$(wget -qO- ipinfo.io/city)"
echo "Weather of $1"
echo " "
wget -qO- "wttr.in/$1?Q0"
fi
echo " "
else
echo "Can't connect to wttr.in"
exit 1
fi
else
if [ "$(ping -c 1 wttr.in)" ]; then
if [ "$(which curl 2>/dev/null)" ]; then
CITY="$(curl -s ipinfo.io/city)"
echo "Weather of $CITY"
echo " "
curl -s "wttr.in/$CITY?Q0"
elif [ "$(which wget 2>/dev/null)" ]; then
CITY="$(wget -qO- ipinfo.io/city)"
echo "Weather of $CITY"
echo " "
wget -qO- "wttr.in/$CITY?Q0"
fi
echo
else
echo "Can't connect to wttr.in"
exit 1
fi
fi
}