Skip to content

Commit

Permalink
add notifications instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
m0wer committed Apr 7, 2024
1 parent 137694a commit 6d02ca0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,34 @@ cp .env.example .env
# edit the .env file
docker compose up -d --build
```

## Notifications for sigunps

Here is an example script that uses `telegram-send` to send a notification
every time someone signs up:

```bash
#!/bin/bash

DIRECTORY_TO_WATCH="/data/idea/data/"

# Check if DIRECTORY_TO_WATCH was provided
if [[ ! -d "$DIRECTORY_TO_WATCH" ]]; then
echo "Error: Directory '$DIRECTORY_TO_WATCH' does not exist."
exit 1
fi

# Using inotifywait to monitor for 'create' and 'modify' events on CSV files
inotifywait -m -e create -e modify -e moved_to --format '%w%f' -q "$DIRECTORY_TO_WATCH" | while read FILE_PATH
do
# Check if the event pertains to a CSV file
if [[ $FILE_PATH == *.csv ]]
then
# Get the last line from the file
LAST_LINE=$(tail -n 1 "$FILE_PATH")

# Send the last line via telegram-send
telegram-send "$(basename $FILE_PATH): $LAST_LINE"
fi
done
```

0 comments on commit 6d02ca0

Please sign in to comment.