forked from shihaam/starlink_status
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
ae44bf94b0 | |||
71095eb629 | |||
ef5d9031e3 | |||
99951c1fb3 | |||
120fec0843 | |||
361b91fad2 | |||
b98e3b6d34 | |||
d143be1ed0 | |||
a588e2807f | |||
d173d6904d | |||
6c96c6efb5 |
@ -2,11 +2,14 @@ FROM archlinux
|
|||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
|
|
||||||
|
# update all
|
||||||
|
RUN pacman -Syu --noconfirm
|
||||||
|
|
||||||
# Basic
|
# Basic
|
||||||
RUN pacman -Sy --noconfirm mpv jq curl bc
|
RUN pacman -S --noconfirm mpv jq curl bc
|
||||||
|
|
||||||
# Ookla Speedtest
|
# Ookla Speedtest
|
||||||
RUN pacman -Sy --noconfirm speedtest-cli
|
RUN pacman -S --noconfirm speedtest-cli
|
||||||
|
|
||||||
# LibreSpeed
|
# LibreSpeed
|
||||||
RUN curl -LOJ https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_linux_amd64.tar.gz \
|
RUN curl -LOJ https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_linux_amd64.tar.gz \
|
||||||
|
100
bot.sh
100
bot.sh
@ -20,7 +20,7 @@ speedtest_upload_meter=data/speedtest_upload_meter_$date.png
|
|||||||
speedtest_meter_image=data/speedtest_meter_image_$date.png
|
speedtest_meter_image=data/speedtest_meter_image_$date.png
|
||||||
weather_file=data/weather_$date.json
|
weather_file=data/weather_$date.json
|
||||||
edited_image=data/edited_image_$date.png
|
edited_image=data/edited_image_$date.png
|
||||||
|
tg_log=data/tg_log_$date.json
|
||||||
#################################################################################
|
#################################################################################
|
||||||
latency(){
|
latency(){
|
||||||
echo $(ping -c 1 $1) | \
|
echo $(ping -c 1 $1) | \
|
||||||
@ -49,7 +49,7 @@ echo Satellite Image grabbed
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
echo Doing speedtest by Ookla
|
echo Doing speedtest by Ookla
|
||||||
# Run speedtest and output to a file
|
# Run speedtest and output to a file
|
||||||
speedtest --json > $speedtest_ookla
|
speedtest --json | tee $speedtest_ookla
|
||||||
# Extract information from the speedtest output
|
# Extract information from the speedtest output
|
||||||
|
|
||||||
# Parsing JSON data
|
# Parsing JSON data
|
||||||
@ -62,6 +62,13 @@ ookla_upload=$(jq '.upload' "$speedtest_ookla")
|
|||||||
ookla_bytes_received=$(jq '.bytes_received' "$speedtest_ookla")
|
ookla_bytes_received=$(jq '.bytes_received' "$speedtest_ookla")
|
||||||
ookla_bytes_sent=$(jq '.bytes_sent' "$speedtest_ookla")
|
ookla_bytes_sent=$(jq '.bytes_sent' "$speedtest_ookla")
|
||||||
|
|
||||||
|
# replacing null values
|
||||||
|
[ -z "$ookla_ping" ] && ookla_ping="-"
|
||||||
|
[ -z "$ookla_download" ] && ookla_download=0
|
||||||
|
[ -z "$ookla_upload" ] && ookla_upload=0
|
||||||
|
[ -z "$ookla_bytes_received" ] && ookla_bytes_received=0
|
||||||
|
[ -z "$ookla_bytes_sent" ] && ookla_bytes_sent=0
|
||||||
|
|
||||||
# Converting to human readable units
|
# Converting to human readable units
|
||||||
ookla_download_mbps=$(echo "scale=2; $ookla_download / 1000000" | bc)
|
ookla_download_mbps=$(echo "scale=2; $ookla_download / 1000000" | bc)
|
||||||
ookla_upload_mbps=$(echo "scale=2; $ookla_upload / 1000000" | bc)
|
ookla_upload_mbps=$(echo "scale=2; $ookla_upload / 1000000" | bc)
|
||||||
@ -70,34 +77,51 @@ ookla_bytes_sent_mb=$(echo "scale=2; $ookla_bytes_sent / 1048576" | bc)
|
|||||||
|
|
||||||
ookla_total=$(echo $ookla_bytes_sent_mb+$ookla_bytes_received_mb | bc)
|
ookla_total=$(echo $ookla_bytes_sent_mb+$ookla_bytes_received_mb | bc)
|
||||||
|
|
||||||
#echo Starting LibreSpeed
|
echo Starting LibreSpeed
|
||||||
#librespeed-cli --json > $speedtest_libre
|
librespeed-cli --json | tee $speedtest_libre
|
||||||
|
|
||||||
# Parsing JSON data
|
# Parsing JSON data
|
||||||
#libre_bytes_sent=$(jq '.[0].bytes_sent' "$speedtest_libre")
|
libre_bytes_sent=$(jq '.[0].bytes_sent' "$speedtest_libre")
|
||||||
#libre_bytes_received=$(jq '.[0].bytes_received' "$speedtest_libre")
|
libre_bytes_received=$(jq '.[0].bytes_received' "$speedtest_libre")
|
||||||
#libre_ping=$(jq '.[0].ping' "$speedtest_libre")
|
libre_ping=$(jq '.[0].ping' "$speedtest_libre")
|
||||||
#libre_upload=$(jq '.[0].upload' "$speedtest_libre")
|
libre_upload=$(jq '.[0].upload' "$speedtest_libre")
|
||||||
#libre_download=$(jq '.[0].download' "$speedtest_libre")
|
libre_download=$(jq '.[0].download' "$speedtest_libre")
|
||||||
#libre_server_name=$(jq -r '.[0].server.name' "$speedtest_libre")
|
libre_server_name=$(jq -r '.[0].server.name' "$speedtest_libre")
|
||||||
|
|
||||||
# Converting to human readable units
|
# replacing null values
|
||||||
#libre_bytes_sent_mb=$(echo "scale=2; $libre_bytes_sent / 1048576" | bc)
|
[ "$libre_ping" = "null" ] || [ -z "$libre_ping" ] && libre_ping="-"
|
||||||
#libre_bytes_received_mb=$(echo "scale=2; $libre_bytes_received / 1048576" | bc)
|
[ "$libre_download" = "null" ] || [ -z "$libre_download" ] && libre_download=0
|
||||||
|
[ "$libre_upload" = "null" ] || [ -z "$libre_upload" ] && libre_upload=0
|
||||||
|
[ "$libre_bytes_received" = "null" ] || [ -z "$libre_bytes_received" ] && libre_bytes_received=0
|
||||||
|
[ "$libre_bytes_sent" = "null" ] || [ -z "$libre_bytes_sent" ] && libre_bytes_sent=0
|
||||||
|
|
||||||
#libre_total=$(echo $libre_bytes_sent_mb+$libre_bytes_received_mb | bc)
|
# Converting to human readable units and replacing null values with 0
|
||||||
|
libre_bytes_sent_mb=$(echo "scale=2; $libre_bytes_sent / 1048576" | bc)
|
||||||
|
libre_bytes_received_mb=$(echo "scale=2; $libre_bytes_received / 1048576" | bc)
|
||||||
|
|
||||||
#echo Starting Fast
|
libre_total=$(echo $libre_bytes_sent_mb+$libre_bytes_received_mb | bc)
|
||||||
#fast --upload --json > $speedtest_fast
|
|
||||||
#fast_download_speed=$(jq '.downloadSpeed' "$speedtest_fast")
|
|
||||||
#fast_upload_speed=$(jq '.uploadSpeed' "$speedtest_fast")
|
|
||||||
#fast_latency=$(jq '.latency' "$speedtest_fast")
|
|
||||||
#fast_downloaded=$(jq '.downloaded' "$speedtest_fast")
|
|
||||||
#fast_uploaded=$(jq '.uploaded' "$speedtest_fast")
|
|
||||||
|
|
||||||
#fast_total=$(echo $fast_downloaded+$fast_uploaded | bc)
|
echo Starting Fast
|
||||||
|
fast --upload --json | tee $speedtest_fast
|
||||||
|
fast_download_speed=$(jq '.downloadSpeed' "$speedtest_fast")
|
||||||
|
fast_upload_speed=$(jq '.uploadSpeed' "$speedtest_fast")
|
||||||
|
fast_latency=$(jq '.latency' "$speedtest_fast")
|
||||||
|
fast_downloaded=$(jq '.downloaded' "$speedtest_fast")
|
||||||
|
fast_uploaded=$(jq '.uploaded' "$speedtest_fast")
|
||||||
|
|
||||||
total_wasted=$ookla_total
|
[ -z "$fast_latency" ] && fast_latency="-"
|
||||||
|
[ -z "$fast_download_speed" ] && fast_download_speed=0
|
||||||
|
[ -z "$fast_upload_speed" ] && fast_upload_speed=0
|
||||||
|
[ -z "$fast_downloaded" ] && fast_downloaded=0
|
||||||
|
[ -z "$fast_uploaded" ] && fast_uploaded=0
|
||||||
|
|
||||||
|
fast_total=$(echo $fast_downloaded+$fast_uploaded | bc)
|
||||||
|
|
||||||
|
average_download=$(echo $ookla_download_mbps+$libre_download+$fast_download_speed/3 | bc)
|
||||||
|
average_upload=$(echo $ookla_upload_mbps+$libre_upload+$fast_upload_speed/3| bc)
|
||||||
|
highest_download=$(echo $ookla_download_mbps $libre_download $fast_download_speed | tr ' ' '\n' | sort -nr | head -n1)
|
||||||
|
highest_upload=$(echo $ookla_upload_mbps $libre_upload $fast_upload_speed | tr ' ' '\n' | sort -nr | head -n1)
|
||||||
|
total_wasted=$(echo $ookla_total+$libre_total+$fast_total | bc)
|
||||||
|
|
||||||
echo Speedtests complete
|
echo Speedtests complete
|
||||||
#################################################################################
|
#################################################################################
|
||||||
@ -106,12 +130,15 @@ echo Speedtests complete
|
|||||||
valorant_ping=$(latency dynamodb.ap-southeast-1.amazonaws.com)
|
valorant_ping=$(latency dynamodb.ap-southeast-1.amazonaws.com)
|
||||||
cfdns_ping=$(latency 1.1.1.1)
|
cfdns_ping=$(latency 1.1.1.1)
|
||||||
googledns_ping=$(latency 8.8.8.8)
|
googledns_ping=$(latency 8.8.8.8)
|
||||||
|
[ -z "$valorant_ping" ] && valorant_ping="-"
|
||||||
|
[ -z "$cfdns_ping" ] && cfdns_ping="-"
|
||||||
|
[ -z "$googledns_ping" ] && googledns_ping="-"
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
#################################################################################
|
#################################################################################
|
||||||
echo Checking weather
|
echo Checking weather
|
||||||
# Make the API request
|
# Make the API request
|
||||||
curl -s "https://api.open-meteo.com/v1/forecast?latitude=${LATITUDE}&longitude=${LONGITUDE}¤t_weather=true" > $weather_file
|
curl -s "https://api.open-meteo.com/v1/forecast?latitude=${LATITUDE}&longitude=${LONGITUDE}¤t_weather=true" | tee $weather_file
|
||||||
# Extract Weather Condition and day or not
|
# Extract Weather Condition and day or not
|
||||||
weather_condition=$(jq '.current_weather.weathercode' "$weather_file")
|
weather_condition=$(jq '.current_weather.weathercode' "$weather_file")
|
||||||
is_day=$(jq '.current_weather.is_day' "$weather_file")
|
is_day=$(jq '.current_weather.is_day' "$weather_file")
|
||||||
@ -150,32 +177,33 @@ echo Weather checked
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
#################################################################################
|
#################################################################################
|
||||||
ookla_download_angle=$(echo "scale=2; -118 + ($ookla_download_mbps - 0) / ($MAX_DOWNLOAD_SPEED - 0) * (118 - -118)" | bc)
|
|
||||||
ookla_upload_angle=$(echo "scale=2; -118 + ($ookla_upload_mbps - 0) / ($MAX_UPLOAD_SPEED - 0) * (118 - -118)" | bc)
|
download_angle=$(echo "scale=2; -118 + ($highest_download - 0) / ($MAX_DOWNLOAD_SPEED - 0) * (118 - -118)" | bc)
|
||||||
|
upload_angle=$(echo "scale=2; -118 + ($highest_upload - 0) / ($MAX_UPLOAD_SPEED - 0) * (118 - -118)" | bc)
|
||||||
|
|
||||||
convert $download_meter \
|
convert $download_meter \
|
||||||
\( $needle -background none \
|
\( $needle -background none \
|
||||||
-rotate $ookla_download_angle \) \
|
-rotate $download_angle \) \
|
||||||
-gravity center \
|
-gravity center \
|
||||||
-compose over \
|
-compose over \
|
||||||
-composite \
|
-composite \
|
||||||
-pointsize 41 \
|
-pointsize 41 \
|
||||||
-font $font \
|
-font $font \
|
||||||
-fill white \
|
-fill white \
|
||||||
-annotate +0+-15 $ookla_download_mbps \
|
-annotate +0+-15 $highest_download \
|
||||||
-annotate +120+85 $MAX_DOWNLOAD_SPEED \
|
-annotate +120+85 $MAX_DOWNLOAD_SPEED \
|
||||||
$speedtest_download_meter
|
$speedtest_download_meter
|
||||||
|
|
||||||
convert $upload_meter \
|
convert $upload_meter \
|
||||||
\( $needle -background none \
|
\( $needle -background none \
|
||||||
-rotate $ookla_upload_angle \) \
|
-rotate $upload_angle \) \
|
||||||
-gravity center \
|
-gravity center \
|
||||||
-compose over \
|
-compose over \
|
||||||
-composite \
|
-composite \
|
||||||
-pointsize 41 \
|
-pointsize 41 \
|
||||||
-font $font \
|
-font $font \
|
||||||
-fill white \
|
-fill white \
|
||||||
-annotate +0+-15 $ookla_upload_mbps \
|
-annotate +0+-15 $highest_upload \
|
||||||
-annotate +120+85 $MAX_UPLOAD_SPEED \
|
-annotate +120+85 $MAX_UPLOAD_SPEED \
|
||||||
$speedtest_upload_meter
|
$speedtest_upload_meter
|
||||||
|
|
||||||
@ -207,6 +235,16 @@ $current_weather
|
|||||||
⬇️ *Download*: $ookla_download_mbps Mbit/s, Used: $ookla_bytes_received_mb MB
|
⬇️ *Download*: $ookla_download_mbps Mbit/s, Used: $ookla_bytes_received_mb MB
|
||||||
⬆️ *Upload*: $ookla_upload_mbps Mbit/s, Used: $ookla_bytes_sent_mb MB
|
⬆️ *Upload*: $ookla_upload_mbps Mbit/s, Used: $ookla_bytes_sent_mb MB
|
||||||
|
|
||||||
|
*LibreSpeed*:
|
||||||
|
🌐 *Server*: $libre_server_name
|
||||||
|
🏓 *Latency*: $libre_ping ms
|
||||||
|
⬇️ *Download*: $libre_download Mbit/s, Used: $libre_bytes_received_mb MB
|
||||||
|
⬆️ *Upload*: $libre_upload Mbit/s, Used $libre_bytes_sent_mb MB
|
||||||
|
|
||||||
|
*Fast Powered by Netflix*:
|
||||||
|
🏓 *Latency*: $fast_latency ms
|
||||||
|
⬇️ *Download*: $fast_download_speed Mbit/s, Used: $fast_downloaded MB
|
||||||
|
⬆️ *Upload*: $fast_upload_speed Mbit/s, Used: $fast_uploaded MB
|
||||||
|
|
||||||
Total data wasted: $total_wasted MB
|
Total data wasted: $total_wasted MB
|
||||||
"
|
"
|
||||||
@ -218,7 +256,7 @@ curl -X POST https://api.telegram.org/bot$TG_BOT_TOKEN/sendMediaGroup \
|
|||||||
-F chat_id=$TG_CHATID \
|
-F chat_id=$TG_CHATID \
|
||||||
-F media='[{"type": "photo", "media": "attach://photo1", "caption": "'"$caption"'", "parse_mode": "Markdown"}, {"type": "photo", "media": "attach://photo2"}]' \
|
-F media='[{"type": "photo", "media": "attach://photo1", "caption": "'"$caption"'", "parse_mode": "Markdown"}, {"type": "photo", "media": "attach://photo2"}]' \
|
||||||
-F photo1=@$speedtest_meter_image \
|
-F photo1=@$speedtest_meter_image \
|
||||||
-F photo2=@$satellite_image >> /dev/null
|
-F photo2=@$satellite_image | tee $tg_log
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
echo Ok done, Sleeping for $DELAY
|
echo Ok done, Sleeping for $DELAY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user