aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Lisina <sekoohaka.sarisan@gmail.com>2025-02-26 02:26:10 +0300
committerMaria Lisina <sekoohaka.sarisan@gmail.com>2025-02-26 02:30:09 +0300
commitd9ed32ce0d9a65251ed60e31ac0590b30500c26f (patch)
tree1dd5b88fbaca51da81b72fc9eb8e25affe6abdba
parent998519456f916b578e7edfbb528a38e444fac521 (diff)
units/ib_name: Move Image Board detection code
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
-rw-r--r--submodules/command_original.sh29
-rw-r--r--submodules/command_post.sh29
-rw-r--r--units/ib_name.sh31
3 files changed, 33 insertions, 56 deletions
diff --git a/submodules/command_original.sh b/submodules/command_original.sh
index 4f0118b..8f8ae90 100644
--- a/submodules/command_original.sh
+++ b/submodules/command_original.sh
@@ -2,34 +2,7 @@
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
-if [ -z "${1}" ]
-then
- reply_text="$(jq -r '.message.reply_to_message.text' "${update}")"
-
- if [ "${reply_text}" = "null" ]
- then
- reply_text="$(jq -r '.message.reply_to_message.caption' "${update}")"
- fi
-
- if [ "${reply_text}" != "null" ]
- then
- ib_reply_name="$(printf "%s" "${reply_text}" | sed '1!d')"
- ib_post_id="$(printf "%s" "${reply_text}" | grep 'ID' | parameter 2)"
-
- for ib_board in ${ascii_table}
- do
- . "${units}/ib_config.sh"
-
- if [ "${ib_reply_name}" = "${ib_name}" ]
- then
- break
- fi
- done
-
- set -- ${ib_board} ${ib_post_id}
- fi
-fi
-
+. "${units}/ib_name.sh"
. "${units}/ib_common.sh"
if [ -n "${output_text}" ]
diff --git a/submodules/command_post.sh b/submodules/command_post.sh
index 5075834..bc0a02c 100644
--- a/submodules/command_post.sh
+++ b/submodules/command_post.sh
@@ -2,34 +2,7 @@
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
-if [ -z "${1}" ]
-then
- reply_text="$(jq -r '.message.reply_to_message.text' "${update}")"
-
- if [ "${reply_text}" = "null" ]
- then
- reply_text="$(jq -r '.message.reply_to_message.caption' "${update}")"
- fi
-
- if [ "${reply_text}" != "null" ]
- then
- ib_reply_name="$(printf "%s" "${reply_text}" | sed '1!d')"
- ib_post_id="$(printf "%s" "${reply_text}" | grep 'ID' | parameter 2)"
-
- for ib_board in ${ascii_table}
- do
- . "${units}/ib_config.sh"
-
- if [ "${ib_reply_name}" = "${ib_name}" ]
- then
- break
- fi
- done
-
- set -- ${ib_board} ${ib_post_id}
- fi
-fi
-
+. "${units}/ib_name.sh"
. "${units}/ib_common.sh"
if [ -n "${output_text}" ]
diff --git a/units/ib_name.sh b/units/ib_name.sh
new file mode 100644
index 0000000..e4cb921
--- /dev/null
+++ b/units/ib_name.sh
@@ -0,0 +1,31 @@
+# Copyright (C) 2024-2025 Maria Lisina
+# Copyright (C) 2024-2025 Danil Lisin
+# SPDX-License-Identifier: Apache-2.0
+
+if [ -z "${1}" ]
+then
+ reply_text="$(jq -r '.message.reply_to_message.text' "${update}")"
+
+ if [ "${reply_text}" = "null" ]
+ then
+ reply_text="$(jq -r '.message.reply_to_message.caption' "${update}")"
+ fi
+
+ if [ "${reply_text}" != "null" ]
+ then
+ ib_reply_name="$(printf "%s" "${reply_text}" | sed '1!d')"
+ ib_post_id="$(printf "%s" "${reply_text}" | grep 'ID' | parameter 2)"
+
+ for ib_board in ${ascii_table}
+ do
+ . "${units}/ib_config.sh"
+
+ if [ "${ib_reply_name}" = "${ib_name}" ]
+ then
+ break
+ fi
+ done
+
+ set -- ${ib_board} ${ib_post_id}
+ fi
+fi