commit 4525ff39495447788a74367211b3d9fd6d067dcf Author: june Date: Fri Feb 14 23:18:23 2025 +1300 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/send_cliff.sh b/send_cliff.sh new file mode 100644 index 0000000..703650d --- /dev/null +++ b/send_cliff.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# .env variables: +# BNRHOOK: discord webhook for the channel +# API: api url for heathcliff image + +# create file if it doesn't exist +LAST_URL_PATH='/home/bread/servers/cliff/latest_url.txt' +touch $LAST_URL_PATH + +# get the last image url +last_img_url=$(cat $LAST_URL_PATH) + +# get current image url +new_img_url=$(curl $API) +echo "got new URL: $new_img_url" + +if [[ "$last_img_url" == "$new_img_url" ]]; then + # if it's the same image just exit + echo "new URL matches previous URL; exiting." + exit 1 +else + # send message to discord + curl --request POST \ + --url "$BNRHOOK" \ + --header 'Content-Type: application/json' \ + --data '{ + "content": "'"$new_img_url"'" + }' + + # write new url to file + echo $new_img_url > $LAST_URL_PATH + exit 0 +fi