aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapod-bot.sh10
1 files changed, 3 insertions, 7 deletions
diff --git a/apod-bot.sh b/apod-bot.sh
index 67e3a04..81fc5c3 100755
--- a/apod-bot.sh
+++ b/apod-bot.sh
@@ -40,13 +40,9 @@ page_link=$apod_base_url/ap$date.html
notice="$title $page_link $media_link"
# Ensure we are not publishing a duplicate notice
-previous_notice=$(curl -sSu "$bot_username:$bot_password" $social_api_url/statuses/home_timeline.json \
- | jq -r '.[0] | .text')
-if [[ "$notice" = "$previous_notice" ]]
-then
- echo "Notice \"$notice\" already published. Aborting..." >&2
- exit 1
-fi
+curl -sSu "$bot_username:$bot_password" $social_api_url/statuses/home_timeline.json \
+ | jq -e --arg notice "$notice" '(.[0] | .text) != $notice' > /dev/null \
+ || (echo "Notice \"$notice\" already published. Aborting..." >&2 && exit 1)
# Check image and page links exist
wget --spider $media_link