diff options
| author | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2025-06-02 06:08:21 +0500 |
|---|---|---|
| committer | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2025-06-02 06:08:21 +0500 |
| commit | a3474e2b7ef1005675bede0494c31b9a8b809f39 (patch) | |
| tree | de95470e53b12bf186663ef047e481752a92fdc5 /auth/moebooru.zsh | |
| parent | 98e3f4749f319be42dc2c519ada73fa3ef751ada (diff) | |
bot: Move Image Board configuration and authorization out
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
Diffstat (limited to 'auth/moebooru.zsh')
| -rw-r--r-- | auth/moebooru.zsh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/auth/moebooru.zsh b/auth/moebooru.zsh new file mode 100644 index 0000000..c3a893d --- /dev/null +++ b/auth/moebooru.zsh @@ -0,0 +1,40 @@ +# Copyright (C) 2024-2025 Maria Lisina +# 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 --data-urlencode "username=${ib_login}" \ + --data-urlencode "api_key=${ib_key}" \ + --get \ + --max-time ${external_timeout} \ + --output "${ib_auth_file}" \ + --proxy "${external_proxy}" \ + --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}" + + . "${units}/log.zsh" + . "${units}/dump.zsh" + + return 0 +fi + +if ! jq -e '.' "${ib_auth_file}" > /dev/null +then + output_text="Invalid username or API key" + log_text="ib_auth (${update_id}): ${output_text}" + + . "${units}/log.zsh" + . "${units}/dump.zsh" + + return 0 +fi + +printf '%s="%s"\n%s="%s"\n' \ + "ib_dfield5" "username=${ib_login}" \ + "ib_dfield6" "api_key=${ib_key}" > "${legacy_file}" |
