Initial Commit
This commit is contained in:
commit
4525ff3949
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.env
|
34
send_cliff.sh
Normal file
34
send_cliff.sh
Normal file
@ -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 [O1
|
||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user