node-toogoodtogo-watcher
Node.js cli tool for monitoring your favorite TooGoodToGo businesses. Notifications are shown when the stock of any of the businesses changes. The following notification types are supported:
- Interactive Telegram bot
- All the notification services that Apprise supports (WIP, see #215).
- Desktop notification
- Console output
Installation
- Install Node.js 18.x or higher (Windows | Linux | OSx).
npm install -g toogoodtogo-watcher
toogoodtogo-watcher config
. Optionally enable / disable certain notifications. See Configuring Telegram notifications for instructions on setting up the Telegram notifications.toogoodtogo-watcher login --email [email protected]
. Click the link in the login email (on PC, not on phone).toogoodtogo-watcher watch
CLI documentation
Usage: toogoodtogo-watcher <command>
Commands:
config Edit the config file.
config-reset Reset the config to the default values.
config-path Show the path of the config file.
login Interactively login via a login email.
watch Watch your favourite busininesses for changes.
Options:
--help Show help [boolean]
--version Show version number [boolean]
Configuring Apprise notifications
Apprise is software for sending notifications. It supports many services.
Running
The easiest way to run the watcher together with Apprise is to use the Docker Compose setup, specified below.
Configuration
- Find your notification service and read the Apprise documentation for that service.
- Follow any prerequisite steps as specified in the documentation.
- Create an 'url' in the format specified in the documentation.
- Add the url to the "apprise.services" section and specify the 'format'.
Configuring the interactive Telegram bot
- Open a Telegram chat with
BotFather
. - Follow the instructions to create your own bot.
- Copy the token and enter it in the configuration via
toogoodtogo-watcher config
, and setenabled
totrue
. - Start the application
toogoodtogo-watcher watch
- Click the
t.me/BOTNAME
link from theBotFather
chat message. - Press
BEGIN
. - Your bot should greet you, and show a notification about your favorites. Note: the bot will show the favorites which you configured. Multiple people can connect to the bot to get updates about these favorites.
Displaying the notifications in the Windows notification center
By default Windows doesn't display the notifications in the notification center. You can enable this by doing the following steps.
- Go to 'notifications & actions settings' (
Windows key
, type 'notifications',enter
) - Click on the 'toast' app at the bottom of the screen.
- Enable the 'show in action center' checkbox.
Docker
Note: the Docker image is a multiarch image. So it will also work on Raspberry Pi's.
Docker run
- Create a directory to store the config file and copy
the config.defaults.json
into
YOUR_FOLDER/config.json
. See above for instructions on how to configure the application. Make sure that the folder has the correct permissions, e.g. run chmod -R o+rwx config/ or you might get access denied errors on the file system. The app needs read/write access on the configuration file, e.g. to store token received in it. - Run the following command to login, using the configured email address. Example: a user
john
who stored the config in~/toogoodtogo-watcher/config.json
:
docker run \
-i \
--name toogoodtogo-watcher \
--rm \
-v ~/toogoodtogo-watcher:/home/node/.config/toogoodtogo-watcher-nodejs \
marklagendijk/toogoodtogo-watcher login --email [email protected]
- Run the following command to start watching.
docker run \
--name toogoodtogo-watcher \
--rm \
-e TZ=Europe/Amsterdam \
-v ~/toogoodtogo-watcher:/home/node/.config/toogoodtogo-watcher-nodejs \
marklagendijk/toogoodtogo-watcher watch
Docker Compose
- Create the following directory structure.
my-docker-compose-stuff │ docker-compose.yaml │ └───toogoodtogo-watcher │ config.json
- Copy
the config.defaults.json
to
toogoodtogo-watcher/config.json
. See above for instructions on how to configure the application. - Use the command as explained under 'Docker run' above to login using the configured email address.
- Create a file
docker-compose.yaml
version: "3" services: toogoodtogo-watcher: image: marklagendijk/toogoodtogo-watcher restart: unless-stopped environment: - TZ=Europe/Amsterdam volumes: - ./toogoodtogo-watcher:/home/node/.config/toogoodtogo-watcher-nodejs # This will make Apprise reachable on apprise:8080 for the other Docker Compose containers apprise: image: caronc/apprise:latest # Enable these to make Apprise reachable from outside Docker # ports: # - "8080:8080"