diff --git a/boorubot.sh b/boorubot.sh index 5451a9b..197e066 100755 --- a/boorubot.sh +++ b/boorubot.sh @@ -53,10 +53,13 @@ TAGS_FMT=`echo "$TAGS" | tr ' ' '\n' | xargs echo | tr ' ' '+'` TAGS_BLK_FMT=`xargs -a "$TAGS_BLACKLIST" echo | sed 's|\ |+-|g'` TAGS_SEARCH="${TAGS_FMT}+sort:random+-${TAGS_BLK_FMT}" -RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&limit=1&tags=${TAGS_SEARCH}"` +# RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&limit=1&tags=${TAGS_SEARCH}"` +RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&tags=${TAGS_SEARCH}"` -URL_FILE="$(echo "$RESULT" | jq -r '. | .post[0].file_url')" -RATING="$(echo "$RESULT" | jq -r '. | .post[0].rating')" +LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')" +SELECTED=`shuf -i 0-$(expr $LENGTH - 1) -n 1` +URL_FILE="$(echo "$RESULT" | jq -r '. | .post['"$SELECTED"'].file_url')" +RATING="$(echo "$RESULT" | jq -r '. | .post['"$SELECTED"'].rating')" NSFW="--nsfw" TEXT="$MSG_NSFW"