From 693abf5cb7a780da7ac57d3f2077b08dc6eb78a2 Mon Sep 17 00:00:00 2001 From: Anon Date: Thu, 11 Apr 2024 22:55:52 -0700 Subject: [PATCH] Updated to make boorubot more reusable --- boorubot.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/boorubot.sh b/boorubot.sh index 606ab68..5451a9b 100755 --- a/boorubot.sh +++ b/boorubot.sh @@ -25,24 +25,29 @@ ABS_PATH="$(readlink -f "$0")" RUN_DIR="$(dirname "$ABS_PATH")" ENTRY="${RUN_DIR}/../FediStatusPoster/runconfig.sh" -DEFAULT_CREDENTIALS="${RUN_DIR}/credentials/hentaibot.sh.gpg" -DEFAULT_KEYFILE="/zfs_media/fs1/BotKeys/hentaibot.sh.key" +# DEFAULT_CREDENTIALS="${RUN_DIR}/credentials/hentaibot.sh.gpg" +# DEFAULT_KEYFILE="/zfs_media/fs1/BotKeys/hentaibot.sh.key" BOORU_URL="gelbooru.com" +POS_ARGS=6 -[ ! $# -ge 4 ] &&\ +[ ! $# -ge $POS_ARGS ] &&\ echo "Invalid number of arguments..." &&\ - echo "$(basename "$0") [blacklist] [searchtags] [msg_sfw] [msg_nsfw] usage:" &&\ + echo "$(basename "$0") [default_credentials] [default_keyfile] [blacklist] [searchtags] [msg_sfw] [msg_nsfw] usage:" &&\ + echo " default_credentials - Path to the credentials file generated by create_app.py" &&\ + echo " default_keyfile - Path to the keyfile if encryption was used for credentials" &&\ echo " blacklist - A text list of newline deliminated tags to blacklist" &&\ echo " searchtags - The tags to search for" &&\ echo " msg_sfw - Display message if image is safe for work" &&\ echo " msg_nsfw - Display message if image is not safe for work" &&\ exit 1 -TAGS_BLACKLIST="$1" -TAGS="$2" -MSG_SFW="$3" -MSG_NSFW="$4" -shift 4 +DEFAULT_CREDENTIALS="$1" +DEFAULT_KEYFILE="$2" +TAGS_BLACKLIST="$3" +TAGS="$4" +MSG_SFW="$5" +MSG_NSFW="$6" +shift $POS_ARGS TAGS_FMT=`echo "$TAGS" | tr ' ' '\n' | xargs echo | tr ' ' '+'` TAGS_BLK_FMT=`xargs -a "$TAGS_BLACKLIST" echo | sed 's|\ |+-|g'` @@ -64,6 +69,7 @@ sleep 1 curl -L -s "$URL_FILE" -o "$PICKED" [ "$RATING" = "general" ] && NSFW="--safe" && TEXT="$MSG_SFW" +[ "$RATING" = "sensitive" ] && NSFW="--safe" && TEXT="$MSG_SFW" [ ! -f "$PICKED" ] && echo "Failed to download: ${PICKED}" && exit 1