aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Lisina <sekoohaka.sarisan@gmail.com>2025-08-27 14:21:29 +0500
committerMaria Lisina <sekoohaka.sarisan@gmail.com>2025-08-27 14:21:29 +0500
commit39f3a9d526b58c95134867f8f353a7aa2e59b088 (patch)
treed09dd9eb65930d6bec85b3e5d10f0beda7f0eb86
parent1177fc62d9979f31e3257ea4127c181933a4cdfa (diff)
units/ib_name: Switch back to dynamic detection
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
-rwxr-xr-xbot.zsh10
-rw-r--r--submodules/command_hash.zsh5
-rw-r--r--units/ib_hash.zsh5
-rw-r--r--units/ib_name.zsh19
4 files changed, 16 insertions, 23 deletions
diff --git a/bot.zsh b/bot.zsh
index ee40edb..0c53e24 100755
--- a/bot.zsh
+++ b/bot.zsh
@@ -37,16 +37,6 @@ units="${dir}/units"
users="${dir}/users"
offset=-1
-board_table=(
- a "Safebooru"
- d "Danbooru"
- g "Gelbooru"
- i "Idol Complex"
- s "Sankaku Channel"
- k "Konachan.com"
- y "yande.re"
-)
-
data_table=(
safebooru "Safebooru"
danbooru "Danbooru"
diff --git a/submodules/command_hash.zsh b/submodules/command_hash.zsh
index 53b8401..549c1fa 100644
--- a/submodules/command_hash.zsh
+++ b/submodules/command_hash.zsh
@@ -24,17 +24,14 @@ do
sleep 1
done
-while [[ ${#board_table} -ge 2 ]]
+for ib_board in {a..z}
do
- ib_board="${board_table[1]}"
. "${units}/ib_hash.zsh" &
if [[ -z "${threaded_hash}" ]]
then
wait
fi
-
- shift 2 board_table
done
if [[ -n "${threaded_hash}" ]]
diff --git a/units/ib_hash.zsh b/units/ib_hash.zsh
index c0f9a01..db26be7 100644
--- a/units/ib_hash.zsh
+++ b/units/ib_hash.zsh
@@ -7,6 +7,11 @@ ib_mode="p"
. "${units}/ib_config.zsh"
. "${units}/ib_authconfig.zsh"
+if [[ -z "${ib_data_url}" ]]
+then
+ exit 0
+fi
+
ib_query="md5:${ib_post_md5}"
ib_hash="$(sha1sum <<< "${user_id}${ib_board}${ib_query}" | cut -d ' ' -f 1)"
diff --git a/units/ib_name.zsh b/units/ib_name.zsh
index 377f056..58133c5 100644
--- a/units/ib_name.zsh
+++ b/units/ib_name.zsh
@@ -28,21 +28,22 @@ fi
ib_reply_name="$(sed '1!d' <<< "${reply_text}")"
-while [[ ${#board_table} -ge 2 ]]
+for ib_board in {a..z} 0
do
- if [[ "${ib_reply_name}" == "${board_table[2]}" ]]
+ . "${units}/ib_config.zsh"
+
+ if [[ "${ib_reply_name}" == "${ib_name}" ]]
then
- ib_board="${board_table[1]}"
break
- elif [[ "${board_table[1]}" == "${board_table[-2]}" ]]
- then
- output_text="Could not find Image Board in replied message"
- return 0
fi
-
- shift 2 board_table
done
+if [[ "${ib_board}" == "0" ]]
+then
+ output_text="Could not find Image Board in replied message"
+ return 0
+fi
+
ib_post_id="$(sed '2!d' <<< "${reply_text}" | cut -d ' ' -f 2)"
if [[ -z "${ib_post_id}" ]]