Display the next departures at any SNCF train station.
Find a file
2023-09-07 12:53:21 +02:00
sncf Fix display issue when departures is an empty list 2022-10-02 19:53:18 +02:00
.gitignore Add HTTP server app 2022-09-19 19:46:26 +02:00
build.sh Generate server static executable 2023-09-07 12:53:21 +02:00
build.ss Add HTTP server app 2022-09-19 19:46:26 +02:00
Dockerfile Smaller docker image for deployment 2022-09-19 22:20:25 +02:00
Dockerfile-build Generate server static executable 2023-09-07 12:53:21 +02:00
fly.toml Smaller docker image for deployment 2022-09-19 22:20:25 +02:00
gerbil.pkg Add build script for the standard package manager 2022-09-11 12:27:33 +02:00
LICENSE Add README 2022-09-09 08:32:07 +02:00
README.org Update Dockerfile to new organization 2022-09-12 18:42:08 +02:00
server.ss Fix issue in params decoding 2022-10-02 19:38:36 +02:00
sncf.ss Handle API error more gracefully 2022-09-20 21:43:30 +02:00

SNCF Bot

Display the next departures at any SNCF train station.

Usage

Get an access to the SNCF API. By creating an account, you should receive an email with your authentication key.

The program reads the authentication key from the SNCF_AUTH_KEY environment variable.

$ export SNCF_AUTH_KEY=<sncf-key>
$ sncf vernon
Prochains départs de Vernon - Giverny (Vernon) :
┌────────┬────────────────────────────┬───────────────┐
│ Réseau │ Direction                  │ Heure         │
├────────┼────────────────────────────┼───────────────┤
│ TER    │ Rouen Rive Droite (Rouen)  │ 12:05         │
│ TER    │ Paris Saint-Lazare (Paris) │ 12:53         │
│ TER    │ Rouen Rive Droite (Rouen)  │ 13:11         │
│ TER    │ Paris Saint-Lazare (Paris) │ 13:56         │
│ TER    │ Paris Saint-Lazare (Paris) │ 14:52         │
│ TER    │ Rouen Rive Droite (Rouen)  │ 15:11         │
│ TER    │ Paris Saint-Lazare (Paris) │ 16:52         │
│ TER    │ Rouen Rive Droite (Rouen)  │ 17:11         │
│ TER    │ Paris Saint-Lazare (Paris) │ 17:56         │
│ TER    │ Rouen Rive Droite (Rouen)  │ 18:04         │
└────────┴────────────────────────────┴───────────────┘

If there are disruptions, the program will display the scheduled and actual (estimated) times of departure, along with the associated messages and explanations.

You can choose the train station with the first argument. The (optional) second argument accepts an ISO 8601-formatted date and time: the program will show departures after this time.

If you want to publish to Mattermost, create an incoming webhook by going to Product menu (top left) → IntegrationsIncoming webhooks.

Use the --mattermost-url option to set the webhook URL and post to Mattermost. Optionally, you can override the default channel of the webhook with --channel.

$ sncf -h
Usage: sncf [option ...] [<station>] [<datetime>]

Options:
 -h --help                        Display this help.
 --mattermost-url  <mattermost-url>  Mattermost incoming webhook URL. [default: #f]
 --channel  <mattermost-channel>  Mattermost channel. [default: #f]

Arguments:
 station:                         Name of the station (default Vernon-Giverny). [default: #f]
 datetime:                        Date and time (ISO 8601 format). [default: #f]

Building instructions

Static executable using Docker

The build script will use Docker to build a fully static executable sncf-static in the current directory. The Dockerfile is based on the gerbil/alpine image.

./build.sh

With your local Gerbil installation

This project depends on dlozeve/fancy. Install it with the package manager:

gxpkg install github.com/dlozeve/fancy

The project comes with a build script for the standard build tool, which installs the sncf executable in $GERBIL_HOME/bin:

./build.ss