From c921b12b8785e1c5c7e66bbee4bcb9a36afc8044 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 25 Feb 2024 18:30:04 +0100 Subject: [PATCH] =?UTF-8?q?#=20my=5FIPCity=20#=20Fonction=20pour=20r=C3=A9?= =?UTF-8?q?cup=C3=A9rer=20la=20g=C3=A9olocalisation=20=C3=A0=20partir=20de?= =?UTF-8?q?=20l'adresse=20IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API/QRCODE.sh | 5 +++++ tools/my.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/API/QRCODE.sh b/API/QRCODE.sh index 234df9ec..df237094 100755 --- a/API/QRCODE.sh +++ b/API/QRCODE.sh @@ -102,8 +102,13 @@ if [[ ${QRCODE} == "station" ]]; then ISTATION=$(cat ~/.zen/tmp/ISTATION) fi + ## FIND STATION GPS CLOSEST ACTIVE KEY + source ~/.zen/GPS + + ## SHOW ZenStation FRONT sed "s~_STATION_~${myIPFS}${ISTATION}/~g" $MY_PATH/../templates/ZenStation/index.html > ~/.zen/tmp/${MOATS}/index.htm + sed -i "s~2L8vaYixCf97DMT8SistvQFeBj7vb6RQL7tvwyiv1XVH~${WORLDG1PUB}~g" ~/.zen/tmp/${MOATS}/index.htm sed -i "s~http://127.0.0.1:8080~${myIPFS}~g" ~/.zen/tmp/${MOATS}/index.htm sed -i "s~http://127.0.0.1:33101~${myG1BILLET}~g" ~/.zen/tmp/${MOATS}/index.htm sed -i "s~http://astroport.localhost:1234~${myASTROPORT}~g" ~/.zen/tmp/${MOATS}/index.htm diff --git a/tools/my.sh b/tools/my.sh index 1d2c3d36..32fefc74 100755 --- a/tools/my.sh +++ b/tools/my.sh @@ -428,6 +428,37 @@ function makecoord() { echo "${input}" } +# Fonction pour récupérer la météo depuis l'API OpenWeatherMap +recuperer_meteo() { + echo "En train de récupérer les données météo..." + # Récupérer la météo à l'aide de l'API OpenWeatherMap + ville="Paris" # Vous pouvez modifier la ville ici + api_key="310103dee4a9d1b716ee27d79f162c7e" # Remplacez YOUR_API_KEY par votre clé API OpenWeatherMap + url="http://api.openweathermap.org/data/2.5/weather?q=$ville&appid=$api_key&units=metric" + meteo=$(curl -s $url) + # Extraire les informations pertinentes de la réponse JSON + temperature=$(echo $meteo | jq -r '.main.temp') + description=$(echo $meteo | jq -r '.weather[0].description') + echo "La météo à $ville : $description, Température: $temperature °C" +} + +# my_IPCity # Fonction pour récupérer la géolocalisation à partir de l'adresse IP +my_IPCity() { + local ip=$1 + + if [ -z "$ip" ]; then + ip=$(curl 'https://api.ipify.org?format=json' --silent | jq -r '.ip') + fi + + local url="http://ip-api.com/json/$ip" + local geolocalisation=$(curl -s "$url") + + local ville=$(echo "$geolocalisation" | jq -r '.city') + local pays=$(echo "$geolocalisation" | jq -r '.country') + + echo "$ville, $pays" +} + IPFSNODEID="$(myIpfsPeerId)" [[ ! $MOATS ]] && MOATS="$(myDate)" isLAN="$(isLan)"