-
-
Save alexshpilkin/075d8b6dcfa8f340f3d4d39b1807eade to your computer and use it in GitHub Desktop.
Watch the Ukrainian CVK website and send push notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
ENDPOINT="https://middleman.ferdinand-muetsch.de/api/messages" | |
if [ "$#" -ne 2 ]; then | |
echo "usage: $0 TOKEN ORIGIN" >&2 | |
exit 1 | |
fi | |
jq -ac --unbuffered --arg token "$1" --arg origin "$2" \ | |
'{"recipient_token": $token, "text": ., "origin": $origin}' | \ | |
while read -r json; do | |
curl -sSL -X POST -H 'Content-Type: application/json' -d "$json" -- "$ENDPOINT" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
"$(dirname "$0")/watchcvk" "$2" ${3-} | \ | |
jq -c --unbuffered --arg url "$2" \ | |
'"Data at \($url) changed:\n\n```html\n\(.)```"' | \ | |
push "$1" PushCVK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
set -o pipefail | |
prev=; data= | |
trap 'rm -f "$prev" "$data"' EXIT | |
prev=$(mktemp); data=$(mktemp) | |
touch -- "$prev" | |
while true; do | |
curl -sSL -- "$1" | iconv -f cp1251 | \ | |
hq 'main > *:not(.noprint)' data >"$data" | |
if diff -q "$prev" "$data" >/dev/null; then :; else | |
jq -Rsc --unbuffered . <"$data" | |
mv "$data" "$prev" | |
fi | |
sleep "${2-60}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment