Skip to content

Commit

Permalink
Add Distance from Receiver feature (#12)
Browse files Browse the repository at this point in the history
* add `MASTODON_LINK_AISCATCHER` support

* Updated `MASTODON_LINK_AISCATCHER`with the link that @jvde-github advised to use

* run `masto_expire` less often

* bug fix

* bug fix

* logging improvement

* add AIS-Catcher link to Discord template

* optimize Dockerfile for size

* optimize Dockerfile

* bug fix

* fix

* initial add of localization of notifications

* bug fix

* bug fix

* updates to l10n

* minor fix

* update force_notify

* add placeholders for addl languages

* Update README.md

* Create discord.template-eses.db

* Rename discord.template-eses.db to discord.template-eses

* Create discord.template-dede

* Update discord.template-eses

* Update masto-l10n-eses.db

* Update shipstatus-eses.db

* Update shiptype-eses.db

* Update save_databases

* Update send_discord

* Update 10-container-init

* Update 40-check-ais-notify

* Update 60-check-mastodon

* Update 80-tropoalert-init

* Update ais-collect

* Update cleanup

* Update notifier-framework

* Update tropo-alert

* Update masto-l10n-nlnl.db

* Update masto-l10n-eses.db

* Update 10-container-init

* Update shipstatus-eses.db

* Update shiptype-frfr.db

Translations by Phil

* Update masto-l10n-frfr.db

Translations by Phil

* Update shipstatus-frfr.db

Translations by Phil

* Update discord.template-frfr

* Update discord.template-dede

* Update masto-l10n-dede.db

* Update shipstatus-dede.db

* Update shiptype-dede.db

* Update masto-l10n-frfr.db

* Update masto-l10n-frfr.db

* Update shiptype-frfr.db

* Update masto-l10n-frfr.db

* Rename discord.template-dede to discord.template-de_DE

* Rename discord.template-enus to discord.template-en_US

* Rename discord.template-eses to discord.template-es_ES

* Rename discord.template-frfr to discord.template-fr_FR

* Rename discord.template-nlnl to discord.template-nl_NL

* Rename masto-l10n-dede.db to masto-l10n-de_DE.db

* Rename masto-l10n-enus.db to masto-l10n-en_US.db

* Rename masto-l10n-eses.db to masto-l10n-es_ES.db

* Rename masto-l10n-frfr.db to masto-l10n-fr_FR.db

* Rename masto-l10n-nlnl.db to masto-l10n-nl_NL.db

* Rename shipstatus-dede.db to shipstatus-de_DE.db

* Rename shipstatus-enus.db to shipstatus-en_US.db

* Rename shipstatus-eses.db to shipstatus-es_ES.db

* Rename shipstatus-frfr.db to shipstatus-fr_FR.db

* Rename shipstatus-nlnl.db to shipstatus-nl_NL.db

* Rename shiptype-dede.db to shiptype-de_DE.db

* Rename shiptype-enus.db to shiptype-en_US.db

* Rename shiptype-eses.db to shiptype-es_ES.db

* Rename shiptype-frfr.db to shiptype-fr_FR.db

* Rename shiptype-nlnl.db to shiptype-nl_NL.db

* Update 10-container-init

* Update send_discord

* Update send_mastodon

* set Mastodon post language to value corresponding to `$LANGUAGE`

* Update send_mastodon

* Update README.md

* Update 70-set-strings

* Update 70-set-strings

* add Distance from Receiver

* pull in changes from main (#11)

* Add aiscatcher link to notifications, slow down `masto_expire` runs to once every 12 hours, Dockerfile optimizations (#9)

* add `MASTODON_LINK_AISCATCHER` support

* Updated `MASTODON_LINK_AISCATCHER`with the link that @jvde-github advised to use

* run `masto_expire` less often

* bug fix

* bug fix

* logging improvement

* add AIS-Catcher link to Discord template

* optimize Dockerfile for size

* optimize Dockerfile

* bug fix

* fix

* Add Localization options for Mastodon and Discord notifications (#10)

* add `MASTODON_LINK_AISCATCHER` support

* Updated `MASTODON_LINK_AISCATCHER`with the link that @jvde-github advised to use

* run `masto_expire` less often

* bug fix

* bug fix

* logging improvement

* add AIS-Catcher link to Discord template

* optimize Dockerfile for size

* optimize Dockerfile

* bug fix

* fix

* initial add of localization of notifications

* bug fix

* bug fix

* updates to l10n

* minor fix

* update force_notify

* add placeholders for addl languages

* Update README.md

* Create discord.template-eses.db

* Rename discord.template-eses.db to discord.template-eses

* Create discord.template-dede

* Update discord.template-eses

* Update masto-l10n-eses.db

* Update shipstatus-eses.db

* Update shiptype-eses.db

* Update save_databases

* Update send_discord

* Update 10-container-init

* Update 40-check-ais-notify

* Update 60-check-mastodon

* Update 80-tropoalert-init

* Update ais-collect

* Update cleanup

* Update notifier-framework

* Update tropo-alert

* Update masto-l10n-nlnl.db

* Update masto-l10n-eses.db

* Update 10-container-init

* Update shipstatus-eses.db

* Update shiptype-frfr.db

Translations by Phil

* Update masto-l10n-frfr.db

Translations by Phil

* Update shipstatus-frfr.db

Translations by Phil

* Update discord.template-frfr

* Update discord.template-dede

* Update masto-l10n-dede.db

* Update shipstatus-dede.db

* Update shiptype-dede.db

* Update masto-l10n-frfr.db

* Update masto-l10n-frfr.db

* Update shiptype-frfr.db

* Update masto-l10n-frfr.db

* Rename discord.template-dede to discord.template-de_DE

* Rename discord.template-enus to discord.template-en_US

* Rename discord.template-eses to discord.template-es_ES

* Rename discord.template-frfr to discord.template-fr_FR

* Rename discord.template-nlnl to discord.template-nl_NL

* Rename masto-l10n-dede.db to masto-l10n-de_DE.db

* Rename masto-l10n-enus.db to masto-l10n-en_US.db

* Rename masto-l10n-eses.db to masto-l10n-es_ES.db

* Rename masto-l10n-frfr.db to masto-l10n-fr_FR.db

* Rename masto-l10n-nlnl.db to masto-l10n-nl_NL.db

* Rename shipstatus-dede.db to shipstatus-de_DE.db

* Rename shipstatus-enus.db to shipstatus-en_US.db

* Rename shipstatus-eses.db to shipstatus-es_ES.db

* Rename shipstatus-frfr.db to shipstatus-fr_FR.db

* Rename shipstatus-nlnl.db to shipstatus-nl_NL.db

* Rename shiptype-dede.db to shiptype-de_DE.db

* Rename shiptype-enus.db to shiptype-en_US.db

* Rename shiptype-eses.db to shiptype-es_ES.db

* Rename shiptype-frfr.db to shiptype-fr_FR.db

* Rename shiptype-nlnl.db to shiptype-nl_NL.db

* Update 10-container-init

* Update send_discord

* Update send_mastodon

* set Mastodon post language to value corresponding to `$LANGUAGE`

* Update send_mastodon

* Update README.md

* Update 70-set-strings

* Update 70-set-strings

* Update docker-compose.yml

* minor layout and text updates

* fix very small logging mislabeling

* minor cleanup

* cleanup

* minor bug fix

* l10n improvement

* fix

* update readme
  • Loading branch information
kx1t committed Jun 14, 2024
1 parent 354f913 commit 7b17816
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions rootfs/opt/data/discord.template-de_DE
Original file line number Diff line number Diff line change
Expand Up @@ -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##)",
Expand Down
5 changes: 5 additions & 0 deletions rootfs/opt/data/discord.template-en_US
Original file line number Diff line number Diff line change
Expand Up @@ -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##)",
Expand Down
5 changes: 5 additions & 0 deletions rootfs/opt/data/discord.template-es_ES
Original file line number Diff line number Diff line change
Expand Up @@ -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##)",
Expand Down
5 changes: 5 additions & 0 deletions rootfs/opt/data/discord.template-fr_FR
Original file line number Diff line number Diff line change
Expand Up @@ -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##)",
Expand Down
5 changes: 5 additions & 0 deletions rootfs/opt/data/discord.template-nl_NL
Original file line number Diff line number Diff line change
Expand Up @@ -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##)",
Expand Down
1 change: 1 addition & 0 deletions rootfs/opt/data/masto-l10n-de_DE.db
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions rootfs/opt/data/masto-l10n-en_US.db
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions rootfs/opt/data/masto-l10n-es_ES.db
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions rootfs/opt/data/masto-l10n-fr_FR.db
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions rootfs/opt/data/masto-l10n-nl_NL.db
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 10 additions & 0 deletions rootfs/usr/share/vesselalert/send_discord
Original file line number Diff line number Diff line change
Expand Up @@ -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//\"\"/\"--\"}"
Expand Down
7 changes: 7 additions & 0 deletions rootfs/usr/share/vesselalert/send_mastodon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 7b17816

Please sign in to comment.