aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md20
-rwxr-xr-xbot.zsh62
-rw-r--r--operators/command_authorize.zsh2
-rw-r--r--units/ib_authconfig.zsh6
-rw-r--r--units/sn_auth.zsh3
-rw-r--r--units/user.zsh1
6 files changed, 31 insertions, 63 deletions
diff --git a/README.md b/README.md
index 63ed8bc..37e3abe 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,6 @@ Options:
-f <secs> Connrefused timeout, max: 2, default: none
-n <addr> Proxy server for Telegram Bot API
-x <addr> Proxy server for Image Boards/SauceNAO API
- -k <key> SauceNAO API key for public use
Cache modes:
none No cache reuse
@@ -71,6 +70,25 @@ Cache modes:
advanced Extract posts cache from inline results
```
+### Default user
+
+You can configure default user to let users without an account on certain Image Board or SauceNAO still have access to it with extended limits
+
+Make sure to turn bot off before any data manipulation
+
+Simply copy desired data from your user directory to `users/0`
+
+| Data | Name |
+| :--- | :--- |
+| `safebooru` | Safebooru |
+| `danbooru` | Danbooru |
+| `idolcomplex` | Idol Complex |
+| `sankakuchannel` | Sankaku Channel |
+| `konachan` | Konachan |
+| `yandere` | Yandere |
+| `saucenao` | SauceNAO |
+
+
## Supported Image Boards
* [Safebooru](https://safebooru.donmai.us/)
diff --git a/bot.zsh b/bot.zsh
index 95e3b29..e057e59 100755
--- a/bot.zsh
+++ b/bot.zsh
@@ -76,7 +76,7 @@ busybox=(
if [[ -n "${1}" ]]
then
- while getopts ha:olg:r:m:t:s:cqi:e:f:n:x:k: opts
+ while getopts ha:olg:r:m:t:s:cqi:e:f:n:x: opts
do
case "${opts}" in
(h)
@@ -127,9 +127,6 @@ then
(x)
external_proxy="${OPTARG}"
;;
- (k)
- sn_key="${OPTARG}"
- ;;
(*)
echo "Unrecognized options" \
"\nSee '${0} -h'"
@@ -620,63 +617,6 @@ else
fi
fi
-if [[ -z "${nocommand_source}" && -n "${sn_key}" ]]
-then
- if ! input_data="$(
- curl --connect-timeout ${connrefused_timeout} \
- --data-urlencode "output_type=2" \
- --data-urlencode "api_key=${sn_key}" \
- --get \
- --max-time ${external_timeout} \
- --proxy "${external_proxy}" \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user-agent "${useragent}" \
- "https://saucenao.com/search.php"
- )"
- then
- log_text="SauceNAO: Failed to access SauceNAO API"
- source "${units}/log.zsh"
-
- exit 1
- fi
-
- if ! jq -e '.' <<< "${input_data}" > /dev/null
- then
- log_text="SauceNAO: An unknown error occurred"
- source "${units}/log.zsh"
-
- exit 1
- fi
-
- sn_status="$(jq -r '.header.status' <<< "${input_data}")"
-
- case "${sn_status}" in
- (-3)
- ;;
- (-2)
- log_text="SauceNAO: Rate limit exceeded, try again later"
- source "${units}/log.zsh"
-
- exit 1
- ;;
- (-1)
- log_text="SauceNAO: Invalid API key"
- source "${units}/log.zsh"
-
- exit 1
- ;;
- (*)
- log_text="SauceNAO: An unknown error occurred"
- source "${units}/log.zsh"
-
- exit 1
- ;;
- esac
-fi
-
log_text="Running help command check..."
source "${units}/log.zsh"
diff --git a/operators/command_authorize.zsh b/operators/command_authorize.zsh
index e4af58d..3512f3f 100644
--- a/operators/command_authorize.zsh
+++ b/operators/command_authorize.zsh
@@ -2,6 +2,8 @@
# Copyright (C) 2024-2026 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
+command_authorize=0
+
if [[ -n "${1}" ]]
then
ib_board="${1}"
diff --git a/units/ib_authconfig.zsh b/units/ib_authconfig.zsh
index 60b41ca..804298d 100644
--- a/units/ib_authconfig.zsh
+++ b/units/ib_authconfig.zsh
@@ -16,6 +16,12 @@ esac
auth_dir="${user_config}/${ib_config}"
+if ! [[ -d "${auth_dir}" || -n "${command_authorize}" ]]
+then
+ user_config="${default_user_config}"
+ auth_dir="${user_config}/${ib_config}"
+fi
+
timestamp_file="${auth_dir}/timestamp"
token_file="${auth_dir}/token"
login_file="${auth_dir}/${ib_login_file}"
diff --git a/units/sn_auth.zsh b/units/sn_auth.zsh
index 67e1e2d..8add23f 100644
--- a/units/sn_auth.zsh
+++ b/units/sn_auth.zsh
@@ -9,8 +9,9 @@ elif [[ -f "${user_config}/saucenao" ]]
then
sn_key="$(< "${user_config}/saucenao")"
return
-elif [[ -n "${sn_key}" ]]
+elif [[ -f "${default_user_config}/saucenao" ]]
then
+ sn_key="$(< "${default_user_config}/saucenao")"
return
else
output_text="You must provide your SauceNAO API key before you can use SauceNAO"
diff --git a/units/user.zsh b/units/user.zsh
index 90de78f..fef02ab 100644
--- a/units/user.zsh
+++ b/units/user.zsh
@@ -24,3 +24,4 @@ then
fi
user_config="${users}/${user_id}"
+default_user_config="${users}/0"