aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Lisina <sekoohaka.sarisan@gmail.com>2025-09-22 17:43:38 +0500
committerMaria Lisina <sekoohaka.sarisan@gmail.com>2025-09-22 17:44:30 +0500
commit53714957d4bed97ecd95005643e7abbd22585df6 (patch)
tree195c0b0eee6fbfdc133b3bdddd04df6602d6327d
parent3acb0da586da283c94ef18e7df792af3cafdfbdf (diff)
auth/*: Update auth units to follow new standard
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
-rw-r--r--README.md1
-rw-r--r--auth/donmai.zsh42
-rw-r--r--auth/moebooru.zsh35
-rw-r--r--auth/sankakucomplex.zsh44
-rwxr-xr-xbot.zsh2
-rw-r--r--units/dump.zsh18
6 files changed, 55 insertions, 87 deletions
diff --git a/README.md b/README.md
index 6064fcc..1836454 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,6 @@ Options:
-s <secs> Sleep duration time, max: 100, default: 10 secs
-c Clear cache automatically
-q Do not print logs
- -u Collect debug dumps
-i <secs> Telegram Bot API connetion timeout, max: 5, default: 5 secs
-e <secs> Image Boards API connetion timeout, max: 5, default: 5 secs
-d <secs> Head request connetion timeout, max: 5, default: 2 secs
diff --git a/auth/donmai.zsh b/auth/donmai.zsh
index f6f445f..e957fd8 100644
--- a/auth/donmai.zsh
+++ b/auth/donmai.zsh
@@ -2,49 +2,45 @@
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
-ib_auth_file="${cache}/${update_id}_profile.json"
-dump+=(${ib_auth_file##*/})
-
-if ! curl --connect-timeout ${connrefused_timeout} \
- --max-time ${external_timeout} \
- --output "${ib_auth_file}" \
- --proxy "${external_proxy}" \
- --request GET \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user "${ib_login}:${ib_key}" \
- --user-agent "${useragent}" \
- "${ib_auth}/profile.json"
+if ! ib_auth_data="$(
+ curl --connect-timeout ${connrefused_timeout} \
+ --max-time ${external_timeout} \
+ --proxy "${external_proxy}" \
+ --request GET \
+ --retry 1 \
+ --retry-connrefused \
+ --retry-max-time $((external_timeout - connrefused_timeout)) \
+ --silent \
+ --user "${ib_login}:${ib_key}" \
+ --user-agent "${useragent}" \
+ "${ib_auth}/profile.json"
+)"
then
output_text="Failed to access ${ib_name} API"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if ! jq -e '.' "${ib_auth_file}" > /dev/null
+if ! jq -e '.' <<< "${ib_auth_data}" > /dev/null
then
output_text="An unknown error occurred"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if [[ "$(jq -r '.success' "${ib_auth_file}")" == "false" ]]
+if [[ "$(jq -r '.success' <<< "${ib_auth_data}")" == "false" ]]
then
- output_text="Error: <code>$(jq -r '.message' "${ib_auth_file}" | htmlescape)</code>"
+ output_text="Error: <code>$(jq -r '.message' <<< "${ib_auth_data}" | htmlescape)</code>"
return 0
fi
-if [[ "$(jq -r '.name' "${ib_auth_file}")" != "${ib_login}" ]]
+if [[ "$(jq -r '.name' <<< "${ib_auth_data}")" != "${ib_login}" ]]
then
output_text="Failed to verify user authorization"
return 0
diff --git a/auth/moebooru.zsh b/auth/moebooru.zsh
index 5458b11..1c3d573 100644
--- a/auth/moebooru.zsh
+++ b/auth/moebooru.zsh
@@ -2,33 +2,30 @@
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
-ib_auth_file="${cache}/${update_id}_user.json"
-dump+=(${ib_auth_file##*/})
-
-if ! curl --connect-timeout ${connrefused_timeout} \
- --data-urlencode "username=${ib_login}" \
- --data-urlencode "api_key=${ib_key}" \
- --get \
- --max-time ${external_timeout} \
- --output "${ib_auth_file}" \
- --proxy "${external_proxy}" \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user-agent "${useragent}" \
- "${ib_auth}/user.json"
+if ! ib_auth_data="$(
+ curl --connect-timeout ${connrefused_timeout} \
+ --data-urlencode "username=${ib_login}" \
+ --data-urlencode "api_key=${ib_key}" \
+ --get \
+ --max-time ${external_timeout} \
+ --proxy "${external_proxy}" \
+ --retry 1 \
+ --retry-connrefused \
+ --retry-max-time $((external_timeout - connrefused_timeout)) \
+ --silent \
+ --user-agent "${useragent}" \
+ "${ib_auth}/user.json"
+)"
then
output_text="Failed to access ${ib_name} API"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if ! jq -e '.' "${ib_auth_file}" > /dev/null
+if ! jq -e '.' <<< "${ib_auth_data}" > /dev/null
then
output_text="Invalid username or API key"
fi
diff --git a/auth/sankakucomplex.zsh b/auth/sankakucomplex.zsh
index 45b9d3a..3eabc78 100644
--- a/auth/sankakucomplex.zsh
+++ b/auth/sankakucomplex.zsh
@@ -9,48 +9,44 @@ ib_login_data="$(
'{"login": $login, "password": $password}'
)"
-ib_auth_file="${cache}/${update_id}_token.json"
-dump+=(${ib_auth_file##*/})
-
-if ! curl --connect-timeout ${connrefused_timeout} \
- --data "${ib_login_data}" \
- --header "Content-Type: application/json" \
- --max-time ${external_timeout} \
- --output "${ib_auth_file}" \
- --proxy "${external_proxy}" \
- --request POST \
- --retry 1 \
- --retry-connrefused \
- --retry-max-time $((external_timeout - connrefused_timeout)) \
- --silent \
- --user-agent "${useragent}" \
- "${ib_auth}/auth/token"
+if ! ib_auth_data="$(
+ curl --connect-timeout ${connrefused_timeout} \
+ --data "${ib_login_data}" \
+ --header "Content-Type: application/json" \
+ --max-time ${external_timeout} \
+ --proxy "${external_proxy}" \
+ --request POST \
+ --retry 1 \
+ --retry-connrefused \
+ --retry-max-time $((external_timeout - connrefused_timeout)) \
+ --silent \
+ --user-agent "${useragent}" \
+ "${ib_auth}/auth/token"
+)"
then
output_text="Failed to access ${ib_name} API"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if ! jq -e '.' "${ib_auth_file}" > /dev/null
+if ! jq -e '.' <<< "${ib_auth_data}" > /dev/null
then
output_text="An unknown error occurred"
- log_text="ib_auth (${update_id}): ${output_text}"
+ log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
- . "${units}/dump.zsh"
return 0
fi
-if [[ "$(jq -r '.success' "${ib_auth_file}")" != "true" ]]
+if [[ "$(jq -r '.success' <<< "${ib_auth_data}")" != "true" ]]
then
- output_text="Error: <code>$(jq -r '.error' "${ib_auth_file}" | htmlescape)</code>"
+ output_text="Error: <code>$(jq -r '.error' <<< "${ib_auth_data}" | htmlescape)</code>"
return 0
fi
-jq -r '.access_token' "${ib_auth_file}" > "${token_file}"
+jq -r '.access_token' <<< "${ib_auth_data}" > "${token_file}"
strftime %s > "${timestamp_file}"
diff --git a/bot.zsh b/bot.zsh
index 81cf686..89595d9 100755
--- a/bot.zsh
+++ b/bot.zsh
@@ -29,7 +29,6 @@ dir="${0%/*}"
auth="${dir}/auth"
cache="${dir}/cache/${$}"
config="${dir}/config"
-dumps="${dir}/dumps/${$}"
files="${dir}/files"
mods="${dir}/modules"
submods="${dir}/submodules"
@@ -172,7 +171,6 @@ then
"\n -s <secs>\tSleep duration time, max: 100, default: 10 secs" \
"\n -c\t\tClear cache automatically" \
"\n -q\t\tDo not print logs" \
- "\n -u\t\tCollect debug dumps" \
"\n -i <secs>\tTelegram Bot API connetion timeout, max: 5, default: 5 secs" \
"\n -e <secs>\tImage Boards API connetion timeout, max: 5, default: 5 secs" \
"\n -d <secs>\tHead request connetion timeout, max: 5, default: 2 secs" \
diff --git a/units/dump.zsh b/units/dump.zsh
deleted file mode 100644
index a514c37..0000000
--- a/units/dump.zsh
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (C) 2024-2025 Maria Lisina
-# Copyright (C) 2024-2025 Danil Lisin
-# SPDX-License-Identifier: Apache-2.0
-
-if [[ -z "${collect_dumps}" ]]
-then
- return 0
-fi
-
-mkdir -p "${dumps}/${update_id}"
-
-for dump_file in ${dump[@]}
-do
- if [[ -f "${cache}/${dump_file}" ]]
- then
- mv "${cache}/${dump_file}" "${dumps}/${update_id}"
- fi
-done