Skip to content

Node.js cli tool for monitoring your favorite TooGoodToGo businesses. Docker image available.

License

Notifications You must be signed in to change notification settings

marklagendijk/node-toogoodtogo-watcher

Repository files navigation

node-toogoodtogo-watcher GitHub license npm Docker Pulls

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

See below for Docker usage.

Installation

  1. Install Node.js 18.x or higher (Windows | Linux | OSx).
  2. npm install -g toogoodtogo-watcher
  3. toogoodtogo-watcher config. Optionally enable / disable certain notifications. See Configuring Telegram notifications for instructions on setting up the Telegram notifications.
  4. toogoodtogo-watcher login --email [email protected]. Click the link in the login email (on PC, not on phone).
  5. 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

  1. Find your notification service and read the Apprise documentation for that service.
  2. Follow any prerequisite steps as specified in the documentation.
  3. Create an 'url' in the format specified in the documentation.
  4. Add the url to the "apprise.services" section and specify the 'format'.

Configuring the interactive Telegram bot

  1. Open a Telegram chat with BotFather.
  2. Follow the instructions to create your own bot.
  3. Copy the token and enter it in the configuration via toogoodtogo-watcher config, and set enabled to true.
  4. Start the application toogoodtogo-watcher watch
  5. Click the t.me/BOTNAME link from the BotFather chat message.
  6. Press BEGIN.
  7. 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.

  1. Go to 'notifications & actions settings' (Windows key, type 'notifications', enter)
  2. Click on the 'toast' app at the bottom of the screen.
  3. 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

  1. 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.
  2. 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]
  1. 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

  1. Create the following directory structure.
    my-docker-compose-stuff
    │   docker-compose.yaml
    │
    └───toogoodtogo-watcher
        │   config.json
    
  2. Copy the config.defaults.json to toogoodtogo-watcher/config.json. See above for instructions on how to configure the application.
  3. Use the command as explained under 'Docker run' above to login using the configured email address.
  4. 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"

About

Node.js cli tool for monitoring your favorite TooGoodToGo businesses. Docker image available.

Resources

License

Stars

Watchers

Forks

Packages

No packages published