output weather to file, added spaces

This commit is contained in:
Shihaam Abdul Rahman 2023-11-11 23:24:02 +05:00
parent 1e627b0bad
commit 31e961529a
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636

18
bot.sh
View File

@ -23,18 +23,18 @@ upload_speed=$(grep -oP 'Upload: \K.*(?= Mbit/s)' $speedtest_result)
################################################################################# #################################################################################
# Make the API request # Make the API request
response=$(curl -s "https://api.open-meteo.com/v1/forecast?latitude=${LATITUDE}&longitude=${LONGITUDE}&current_weather=true" > $weather_file) curl -s "https://api.open-meteo.com/v1/forecast?latitude=${LATITUDE}&longitude=${LONGITUDE}&current_weather=true" > $weather_file
# Extract Weather Condition # Extract Weather Condition
weather_condition=$(cat $weather_file | jq '.current_weather.weathercode') weather_condition=$(cat $weather_file | jq '.current_weather.weathercode')
case $weather_condition in case $weather_condition in
0) current_weather="☀️ Clear sky" ;; 0) current_weather="☀️ Clear sky" ;;
1|2|3) current_weather="☁️ Cloudy" ;; 1|2|3) current_weather="☁️ Cloudy" ;;
45|48) current_weather="🌫️ Fog" ;; 45|48) current_weather="🌫️ Fog" ;;
51|53|55|56|57) current_weather="🌧️ Drizzle" ;; 51|53|55|56|57) current_weather="🌧️ Drizzle" ;;
61|63|65|66|67) current_weather="🌦️ Rain" ;; 61|63|65|66|67) current_weather="🌦️ Rain" ;;
80|81|82) current_weather="🌧️ Rain showers" ;; 80|81|82) current_weather="🌧️ Rain showers" ;;
85|86) current_weather="🌨️ Snow showers" ;; 85|86) current_weather="🌨️ Snow showers" ;;
95|96|99) current_weather="⛈️ Thunderstorm" ;; 95|96|99) current_weather="⛈️ Thunderstorm" ;;
*) current_weather="🌐 Weather condition not recognized" ;; *) current_weather="🌐 Weather condition not recognized" ;;
esac esac
################################################################################# #################################################################################