Updated to make boorubot more reusable

This commit is contained in:
Anon 2024-04-11 22:55:52 -07:00
parent c782c34cd2
commit 693abf5cb7

View File

@ -25,24 +25,29 @@ ABS_PATH="$(readlink -f "$0")"
RUN_DIR="$(dirname "$ABS_PATH")" RUN_DIR="$(dirname "$ABS_PATH")"
ENTRY="${RUN_DIR}/../FediStatusPoster/runconfig.sh" ENTRY="${RUN_DIR}/../FediStatusPoster/runconfig.sh"
DEFAULT_CREDENTIALS="${RUN_DIR}/credentials/hentaibot.sh.gpg" # DEFAULT_CREDENTIALS="${RUN_DIR}/credentials/hentaibot.sh.gpg"
DEFAULT_KEYFILE="/zfs_media/fs1/BotKeys/hentaibot.sh.key" # DEFAULT_KEYFILE="/zfs_media/fs1/BotKeys/hentaibot.sh.key"
BOORU_URL="gelbooru.com" BOORU_URL="gelbooru.com"
POS_ARGS=6
[ ! $# -ge 4 ] &&\ [ ! $# -ge $POS_ARGS ] &&\
echo "Invalid number of arguments..." &&\ 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 " blacklist - A text list of newline deliminated tags to blacklist" &&\
echo " searchtags - The tags to search for" &&\ echo " searchtags - The tags to search for" &&\
echo " msg_sfw - Display message if image is safe for work" &&\ echo " msg_sfw - Display message if image is safe for work" &&\
echo " msg_nsfw - Display message if image is not safe for work" &&\ echo " msg_nsfw - Display message if image is not safe for work" &&\
exit 1 exit 1
TAGS_BLACKLIST="$1" DEFAULT_CREDENTIALS="$1"
TAGS="$2" DEFAULT_KEYFILE="$2"
MSG_SFW="$3" TAGS_BLACKLIST="$3"
MSG_NSFW="$4" TAGS="$4"
shift 4 MSG_SFW="$5"
MSG_NSFW="$6"
shift $POS_ARGS
TAGS_FMT=`echo "$TAGS" | tr ' ' '\n' | xargs echo | tr ' ' '+'` TAGS_FMT=`echo "$TAGS" | tr ' ' '\n' | xargs echo | tr ' ' '+'`
TAGS_BLK_FMT=`xargs -a "$TAGS_BLACKLIST" echo | sed 's|\ |+-|g'` TAGS_BLK_FMT=`xargs -a "$TAGS_BLACKLIST" echo | sed 's|\ |+-|g'`
@ -64,6 +69,7 @@ sleep 1
curl -L -s "$URL_FILE" -o "$PICKED" curl -L -s "$URL_FILE" -o "$PICKED"
[ "$RATING" = "general" ] && NSFW="--safe" && TEXT="$MSG_SFW" [ "$RATING" = "general" ] && NSFW="--safe" && TEXT="$MSG_SFW"
[ "$RATING" = "sensitive" ] && NSFW="--safe" && TEXT="$MSG_SFW"
[ ! -f "$PICKED" ] && echo "Failed to download: ${PICKED}" && exit 1 [ ! -f "$PICKED" ] && echo "Failed to download: ${PICKED}" && exit 1