diff --git a/README.md b/README.md index b23c969..a063b15 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ There are a series of available environment variables: | `NOTIFY_ONLY_NEW_ON_STARTUP` | If set to any non-empty value, when restarting the container, it will not notify for any vessels in its first run, and consider these vessels "already notified". This is to avoid spamming the notification service at initial startup when many non-notified vessels are discovered | empty | no | | `NOTIFICATION_THROTTLE` | If set to any non-empty value, notifications will pause for 15 seconds for every 10 notifications in a run | empty | no | | `LANGUAGE` | Set to make notifications in one of these supported languages: `en_US` (US English); `es_ES` (Spanish); `nl_NL` (Dutch); `fr_FR` (French); `de_DE` (German). If omitted, it will default to `en_US` | `en_US` | no | +| `LAT` | Latitude of receiver station. If Lat/Lon are included, the notification will contain a "Distance to Receiver" field | empty | no | +| `LON` | Longitude of receiver station. If Lat/Lon are included, the notification will contain a "Distance to Receiver" field | empty | no | ### Tropo Alert parameters diff --git a/rootfs/opt/data/discord.template-de_DE b/rootfs/opt/data/discord.template-de_DE index 5dd5e62..9df835b 100644 --- a/rootfs/opt/data/discord.template-de_DE +++ b/rootfs/opt/data/discord.template-de_DE @@ -65,6 +65,10 @@ "value": "##HEADING## ", "inline": false }, + "name": "Entfernung vom Empfänger", + "value": "##DISTANCE## nm", + "inline": false + },--HASDIST## { "name": "Externe Links", "value": "##SM--[Station Map](##STNMAP##) | --SM##[AIS-Catcher](https://aiscatcher.org/ship/details/##MMSI##) | [ShipXplorer](https://www.shipxplorer.com/data/vessels/IMO-MMSI-##MMSI##) | [MarineTraffic](https://www.marinetraffic.com/en/ais/details/ships/##MMSI##) | [VesselFinder](https://www.vesselfinder.com/vessels/details/##MMSI##) | [ShipSpotting photo gallery](https://www.shipspotting.com/photos/gallery?mmsi=##MMSI##)", diff --git a/rootfs/opt/data/discord.template-en_US b/rootfs/opt/data/discord.template-en_US index 3ad5666..08d7c70 100644 --- a/rootfs/opt/data/discord.template-en_US +++ b/rootfs/opt/data/discord.template-en_US @@ -65,6 +65,11 @@ "value": "##HEADING## ", "inline": false }, + ##HASDIST--{ + "name": "Distance from receiver", + "value": "##DISTANCE## nm", + "inline": false + },--HASDIST## { "name": "External Links", "value": "##SM--[Station Map](##STNMAP##) | --SM##[AIS-Catcher](https://aiscatcher.org/ship/details/##MMSI##) | [ShipXplorer](https://www.shipxplorer.com/data/vessels/IMO-MMSI-##MMSI##) | [MarineTraffic](https://www.marinetraffic.com/en/ais/details/ships/##MMSI##) | [VesselFinder](https://www.vesselfinder.com/vessels/details/##MMSI##) | [ShipSpotting photo gallery](https://www.shipspotting.com/photos/gallery?mmsi=##MMSI##)", diff --git a/rootfs/opt/data/discord.template-es_ES b/rootfs/opt/data/discord.template-es_ES index c2050b0..c266ae4 100644 --- a/rootfs/opt/data/discord.template-es_ES +++ b/rootfs/opt/data/discord.template-es_ES @@ -65,6 +65,11 @@ "value": "##HEADING## ", "inline": false }, + ##HASDIST--{ + "name": "Distancia del receptor", + "value": "##DISTANCE## nm", + "inline": false + },--HASDIST## { "name": "Enlaces Externos", "value": "##SM--[Station Map](##STNMAP##) | --SM##[AIS-Catcher](https://aiscatcher.org/ship/details/##MMSI##) | [ShipXplorer](https://www.shipxplorer.com/data/vessels/IMO-MMSI-##MMSI##) | [MarineTraffic](https://www.marinetraffic.com/en/ais/details/ships/##MMSI##) | [VesselFinder](https://www.vesselfinder.com/vessels/details/##MMSI##) | [ShipSpotting photo gallery](https://www.shipspotting.com/photos/gallery?mmsi=##MMSI##)", diff --git a/rootfs/opt/data/discord.template-fr_FR b/rootfs/opt/data/discord.template-fr_FR index 4dd33f1..ef15f21 100644 --- a/rootfs/opt/data/discord.template-fr_FR +++ b/rootfs/opt/data/discord.template-fr_FR @@ -65,6 +65,11 @@ "value": "##HEADING## ", "inline": false }, + ##HASDIST--{ + "name": "Distance du récepteur", + "value": "##DISTANCE## nm", + "inline": false + },--HASDIST## { "name": "Liens externes", "value": "##SM--[Station Map](##STNMAP##) | --SM##[AIS-Catcher](https://aiscatcher.org/ship/details/##MMSI##) | [ShipXplorer](https://www.shipxplorer.com/data/vessels/IMO-MMSI-##MMSI##) | [MarineTraffic](https://www.marinetraffic.com/en/ais/details/ships/##MMSI##) | [VesselFinder](https://www.vesselfinder.com/vessels/details/##MMSI##) | [ShipSpotting photo gallery](https://www.shipspotting.com/photos/gallery?mmsi=##MMSI##)", diff --git a/rootfs/opt/data/discord.template-nl_NL b/rootfs/opt/data/discord.template-nl_NL index 1a70911..ebc0192 100644 --- a/rootfs/opt/data/discord.template-nl_NL +++ b/rootfs/opt/data/discord.template-nl_NL @@ -65,6 +65,11 @@ "value": "##HEADING## ", "inline": false }, + ##HASDIST--{ + "name": "Afstand van ontvanger", + "value": "##DISTANCE## nm", + "inline": false + },--HASDIST## { "name": "Externe Links", "value": "##SM--[Station Map](##STNMAP##) | --SM##[AIS-Catcher](https://aiscatcher.org/ship/details/##MMSI##) | [ShipXplorer](https://www.shipxplorer.com/data/vessels/IMO-MMSI-##MMSI##) | [MarineTraffic](https://www.marinetraffic.com/en/ais/details/ships/##MMSI##) | [VesselFinder](https://www.vesselfinder.com/vessels/details/##MMSI##) | [ShipSpotting photo gallery](https://www.shipspotting.com/photos/gallery?mmsi=##MMSI##)", diff --git a/rootfs/opt/data/masto-l10n-de_DE.db b/rootfs/opt/data/masto-l10n-de_DE.db index d8aa30e..fc281a4 100644 --- a/rootfs/opt/data/masto-l10n-de_DE.db +++ b/rootfs/opt/data/masto-l10n-de_DE.db @@ -37,3 +37,4 @@ MASTO_TERM[ISSEENON]="beobachtet um" MASTO_TERM[AGAIN]="Wiederholung:" MASTO_TERM[NEW2]="Neu:" MASTO_TERM[DIST_SINCE_LAST]="hat sich seit der letzten Meldung um %.1f sm bewegt" +MASTO_TERM[DISTANCE]="Entfernung vom Empfänger" diff --git a/rootfs/opt/data/masto-l10n-en_US.db b/rootfs/opt/data/masto-l10n-en_US.db index 4b1359e..5067b58 100644 --- a/rootfs/opt/data/masto-l10n-en_US.db +++ b/rootfs/opt/data/masto-l10n-en_US.db @@ -37,3 +37,4 @@ MASTO_TERM[ISSEENON]="is seen on" MASTO_TERM[AGAIN]="Again:" MASTO_TERM[NEW2]="New:" MASTO_TERM[DIST_SINCE_LAST]="moved %.1f nm since last notification" +MASTO_TERM[DISTANCE]="Distance from receiver" \ No newline at end of file diff --git a/rootfs/opt/data/masto-l10n-es_ES.db b/rootfs/opt/data/masto-l10n-es_ES.db index 9889335..3495f92 100644 --- a/rootfs/opt/data/masto-l10n-es_ES.db +++ b/rootfs/opt/data/masto-l10n-es_ES.db @@ -37,3 +37,4 @@ MASTO_TERM[ISSEENON]="fue visto a la hora" MASTO_TERM[AGAIN]="Nuevamente:" MASTO_TERM[NEW2]="Nuevo:" MASTO_TERM[DIST_SINCE_LAST]="se ha transladado %.1f nm desde la última notificación" +MASTO_TERM[DISTANCE]="Distancia del receptor" diff --git a/rootfs/opt/data/masto-l10n-fr_FR.db b/rootfs/opt/data/masto-l10n-fr_FR.db index 73e568c..c448508 100644 --- a/rootfs/opt/data/masto-l10n-fr_FR.db +++ b/rootfs/opt/data/masto-l10n-fr_FR.db @@ -36,3 +36,4 @@ MASTO_TERM[ISSEENON]="est vu à" MASTO_TERM[AGAIN]="A nouveau:" MASTO_TERM[NEW2]="Nouveau:" MASTO_TERM[DIST_SINCE_LAST]="déplacé de %.1f nm depuis la dernière notification" +MASTO_TERM[DISTANCE]="Distance du récepteur" diff --git a/rootfs/opt/data/masto-l10n-nl_NL.db b/rootfs/opt/data/masto-l10n-nl_NL.db index c564585..d328b77 100644 --- a/rootfs/opt/data/masto-l10n-nl_NL.db +++ b/rootfs/opt/data/masto-l10n-nl_NL.db @@ -36,3 +36,4 @@ MASTO_TERM[ISSEENON]="is gezien om" MASTO_TERM[AGAIN]="Herhaling:" MASTO_TERM[NEW2]="Nieuw:" MASTO_TERM[DIST_SINCE_LAST]="%.1f nm verplaatst sinds de vorige notificatie" +MASTO_TERM[DISTANCE]="Afstand van ontvanger" diff --git a/rootfs/usr/share/vesselalert/send_discord b/rootfs/usr/share/vesselalert/send_discord index f1672a2..7978d69 100755 --- a/rootfs/usr/share/vesselalert/send_discord +++ b/rootfs/usr/share/vesselalert/send_discord @@ -183,6 +183,16 @@ notif_json="${notif_json//##COUNT##/${VESSELS[$1:count]}}" notif_json="${notif_json//##TIMESTAMP##/${timestamp}}" } +if [[ -n "${VESSELS[$1:lat]}" ]] && [[ -n "${VESSELS[$1:lon]}" ]] && [[ -n "$LAT" ]] && [[ -n "$LON" ]]; then + distance="$(bc -l <<< "scale=1; $(distance "${VESSELS[$1:lat]}" "${VESSELS[$1:lon]}" "$LAT" "$LON") / 1")" + notif_json="${notif_json//##DISTANCE##/${distance}}" + notif_json="${notif_json//##HASDIST--/}" + notif_json="${notif_json//--HASDIST##/}" +else + notif_json="${notif_json//##HASDIST--*--HASDIST##/}" +fi + + # replace " " and "" by "--" to appease Discord's weird restriction on empty and almost empty strings notif_json="${notif_json//\" \"/\"--\"}" notif_json="${notif_json//\"\"/\"--\"}" diff --git a/rootfs/usr/share/vesselalert/send_mastodon b/rootfs/usr/share/vesselalert/send_mastodon index 9ae0775..f0d0e5a 100755 --- a/rootfs/usr/share/vesselalert/send_mastodon +++ b/rootfs/usr/share/vesselalert/send_mastodon @@ -78,6 +78,7 @@ unset mast_str if [[ -n "$notify_tropo" ]]; then mast_str="#${MASTO_TERM[TROPOMAXDIST]} = $(printf "%.1f" "${VESSELS[$1:distance]}") nm\n" fi + mast_str+="#VesselAlert" [[ "${MASTO_TERM[SHIP]}" != "Ship" ]] && mast_str+=" #${MASTO_TERM[SHIP]}" || true [[ -z "${VESSELS[$1:notification:last]}" ]] && mast_str+=" ${MASTO_TERM[NEW]}" || true @@ -97,6 +98,12 @@ mast_str+="${MASTO_TERM[SEEN_ON]}: $(date -d @$(( $(date +%s) - ${VESSELS[$1:las [[ -n "${VESSELS[$1:speed]}" ]] && [[ "${VESSELS[$1:speed]}" != "0" ]] && [[ "${VESSELS[$1:speed]}" != "null" ]] && mast_str+="${MASTO_TERM[SPEED]}: $(printf "%.1f" "${VESSELS[$1:speed]}") kts " || true [[ -n "${VESSELS[$1:heading]}" ]] && [[ "${VESSELS[$1:heading]}" != "0" ]] && [[ "${VESSELS[$1:heading]}" != "null" ]] && mast_str+="${MASTO_TERM[HEADING]}: ${VESSELS[$1:heading]} deg " || true [[ -n "${VESSELS[$1:destination]}" ]] && mast_str+="${MASTO_TERM[DESTINATION]}: ${VESSELS[$1:destination]}\n" || true + +if [[ -n "${VESSELS[$1:lat]}" ]] && [[ -n "${VESSELS[$1:lon]}" ]] && [[ -n "$LAT" ]] && [[ -n "$LON" ]]; then + distance="$(bc -l <<< "scale=1; $(distance "${VESSELS[$1:lat]}" "${VESSELS[$1:lon]}" "$LAT" "$LON") / 1")" + mast_str+="${MASTO_TERM[DISTANCE]}: $distance nm\n" +fi + mast_str+="\n" mast_str+="${MASTO_TERM[SIGNAL]} #RSSI: $(printf "%.1f dBFS" "${VESSELS[$1:level]}")\n"