diff options
| author | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2025-05-19 18:01:39 +0500 |
|---|---|---|
| committer | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2025-05-19 18:01:39 +0500 |
| commit | 03a7c5b049ff7ba50330c77452575133f84e386e (patch) | |
| tree | f79ff366d099de59631e9936ee58f01a482f08e6 /units | |
| parent | 0ff0b7f0e6b99aedc52c031e476ec85cb6702c97 (diff) | |
bot: Begin porting to Z Shell
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
Diffstat (limited to 'units')
| -rw-r--r-- | units/dump.zsh (renamed from units/dump.sh) | 6 | ||||
| -rw-r--r-- | units/help.zsh (renamed from units/help.sh) | 0 | ||||
| -rw-r--r-- | units/ib_auth.zsh (renamed from units/ib_auth.sh) | 50 | ||||
| -rw-r--r-- | units/ib_authconfig.zsh (renamed from units/ib_authconfig.sh) | 0 | ||||
| -rw-r--r-- | units/ib_cache.zsh (renamed from units/ib_cache.sh) | 2 | ||||
| -rw-r--r-- | units/ib_common.zsh (renamed from units/ib_common.sh) | 18 | ||||
| -rw-r--r-- | units/ib_config.zsh (renamed from units/ib_config.sh) | 74 | ||||
| -rw-r--r-- | units/ib_date.zsh (renamed from units/ib_date.sh) | 6 | ||||
| -rw-r--r-- | units/ib_file.zsh (renamed from units/ib_file.sh) | 30 | ||||
| -rw-r--r-- | units/ib_hash.zsh (renamed from units/ib_hash.sh) | 8 | ||||
| -rw-r--r-- | units/ib_lock.zsh (renamed from units/ib_lock.sh) | 2 | ||||
| -rw-r--r-- | units/ib_meta.zsh (renamed from units/ib_meta.sh) | 36 | ||||
| -rw-r--r-- | units/ib_name.zsh (renamed from units/ib_name.sh) | 12 | ||||
| -rw-r--r-- | units/ib_original.zsh (renamed from units/ib_original.sh) | 10 | ||||
| -rw-r--r-- | units/ib_post.zsh (renamed from units/ib_post.sh) | 45 | ||||
| -rw-r--r-- | units/ib_preview.zsh (renamed from units/ib_preview.sh) | 2 | ||||
| -rw-r--r-- | units/ib_sample.zsh (renamed from units/ib_sample.sh) | 2 | ||||
| -rw-r--r-- | units/ib_search.zsh (renamed from units/ib_search.sh) | 52 | ||||
| -rw-r--r-- | units/ib_size.zsh (renamed from units/ib_size.sh) | 4 | ||||
| -rw-r--r-- | units/ib_token.zsh (renamed from units/ib_token.sh) | 12 | ||||
| -rw-r--r-- | units/log.zsh (renamed from units/log.sh) | 2 | ||||
| -rw-r--r-- | units/shorts_search.sh | 110 | ||||
| -rw-r--r-- | units/shorts_search.zsh | 94 | ||||
| -rw-r--r-- | units/sn_auth.zsh (renamed from units/sn_auth.sh) | 18 | ||||
| -rw-r--r-- | units/sn_get.zsh (renamed from units/sn_get.sh) | 40 | ||||
| -rw-r--r-- | units/sn_search.zsh (renamed from units/sn_search.sh) | 14 | ||||
| -rw-r--r-- | units/user.sh | 27 | ||||
| -rw-r--r-- | units/user.zsh | 24 |
28 files changed, 329 insertions, 371 deletions
diff --git a/units/dump.sh b/units/dump.zsh index 904d012..8c857da 100644 --- a/units/dump.sh +++ b/units/dump.zsh @@ -2,19 +2,19 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -z "${collect_dumps}" ] +if [[ -z "${collect_dumps}" ]] then return 0 fi -if [ -n "${dump}" ] +if [[ -n "${dump}" ]] then mkdir -p "${dumps}/${update_id}" fi for cache_dump in ${dump} do - if [ -f "${cache}/${cache_dump}" ] + if [[ -f "${cache}/${cache_dump}" ]] then cp "${cache}/${cache_dump}" "${dumps}/${update_id}" fi diff --git a/units/help.sh b/units/help.zsh index ffc9de0..ffc9de0 100644 --- a/units/help.sh +++ b/units/help.zsh diff --git a/units/ib_auth.sh b/units/ib_auth.zsh index 20c16dc..444e746 100644 --- a/units/ib_auth.sh +++ b/units/ib_auth.zsh @@ -2,9 +2,9 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -z "${ib_login}" ] +if [[ -z "${ib_login}" ]] then - if [ -f "${user_config}/${ib_config}/${ib_login_file}" ] + if [[ -f "${user_config}/${ib_config}/${ib_login_file}" ]] then ib_login="$(cat "${user_config}/${ib_config}/${ib_login_file}")" else @@ -13,9 +13,9 @@ then fi fi -if [ -z "${ib_key}" ] +if [[ -z "${ib_key}" ]] then - if [ -f "${user_config}/${ib_config}/${ib_key_file}" ] + if [[ -f "${user_config}/${ib_config}/${ib_key_file}" ]] then ib_key="$(cat "${user_config}/${ib_config}/${ib_key_file}")" else @@ -47,8 +47,8 @@ case "${ib_board}" in output_text="Failed to process request" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -58,30 +58,30 @@ case "${ib_board}" in output_text="An unknown error occurred" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi - if [ "$(jq -r '.success' "${ib_auth_file}")" = "false" ] + if [[ "$(jq -r '.success' "${ib_auth_file}")" = "false" ]] then output_text="Error: <code>$(jq -r '.message' "${ib_auth_file}" | htmlescape)</code>" log_text="ib_auth (${update_id}): $(jq -r '.message' "${ib_auth_file}")" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi - if [ "$(jq -r '.name' "${ib_auth_file}")" != "${ib_login}" ] + if [[ "$(jq -r '.name' "${ib_auth_file}")" != "${ib_login}" ]] then output_text="An unexpected error occurred" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -125,8 +125,8 @@ case "${ib_board}" in output_text="Failed to process request" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -136,19 +136,19 @@ case "${ib_board}" in output_text="An unknown error occurred" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi - if [ "$(jq -r '.success' "${ib_auth_file}")" != "true" ] + if [[ "$(jq -r '.success' "${ib_auth_file}")" != "true" ]] then output_text="Error: <code>$(jq -r '.error' "${ib_auth_file}" | htmlescape)</code>" log_text="ib_auth (${update_id}): $(jq -r '.error' "${ib_auth_file}")" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -173,8 +173,8 @@ case "${ib_board}" in output_text="Failed to process request" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -184,8 +184,8 @@ case "${ib_board}" in output_text="Invalid username or API key" log_text="ib_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi diff --git a/units/ib_authconfig.sh b/units/ib_authconfig.zsh index 31dc7ba..31dc7ba 100644 --- a/units/ib_authconfig.sh +++ b/units/ib_authconfig.zsh diff --git a/units/ib_cache.sh b/units/ib_cache.zsh index cd6946c..0f4c604 100644 --- a/units/ib_cache.sh +++ b/units/ib_cache.zsh @@ -10,7 +10,7 @@ done ib_post="$(jq -c ".${ib_iarray}[${array_count}]" "${ib_file}")" ib_file="${cache}/${ib_hash}.json" -if [ -n "${ib_iarray}" ] +if [[ -n "${ib_iarray}" ]] then printf '{"%s":[%s]}' "${ib_iarray}" "${ib_post}" | jq -c > "${ib_file}" else diff --git a/units/ib_common.sh b/units/ib_common.zsh index 43ad6e9..9ee1b09 100644 --- a/units/ib_common.sh +++ b/units/ib_common.zsh @@ -2,15 +2,15 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${1}" ] +if [[ -n "${1}" ]] then ib_board="${1}" ib_mode="p" - . "${units}/ib_config.sh" - . "${units}/ib_authconfig.sh" + . "${units}/ib_config.zsh" + . "${units}/ib_authconfig.zsh" - if [ -z "${ib_data_url}" ] + if [[ -z "${ib_data_url}" ]] then output_title="Invalid arguments" output_text="Unsupported image board" @@ -28,22 +28,22 @@ else return 0 fi -if [ -n "${1}" ] +if [[ -n "${1}" ]] then ib_post_id="${1}" shift else output_title="Invalid arguments" - output_text="You must specify the post ID or the MD5 hash" + output_text="You must specify the post ID or the MD5 h.zsh" notification_text="${output_text}" return 0 fi -if [ ${#ib_post_id} -eq 32 ] +if [[ ${#ib_post_id} -eq 32 ]] then ib_query="md5:${ib_post_id}" -elif [ "${ib_name}" = "Idol Complex" ] +elif [[ "${ib_name}" = "Idol Complex" ]] then ib_query="id_range:${ib_post_id}" else @@ -51,4 +51,4 @@ else fi ib_hash="$(printf "%s%s%s" "${user_id}" "${ib_board}" "${ib_post_id}" | enhash)" -. "${units}/ib_file.sh" +. "${units}/ib_file.zsh" diff --git a/units/ib_config.sh b/units/ib_config.zsh index fcd0bcf..070ae20 100644 --- a/units/ib_config.sh +++ b/units/ib_config.zsh @@ -21,20 +21,20 @@ case "${ib_board}" in ;; esac - ib_ratings=" + ib_ratings=( g general s sensitive q questionable e explicit - " + ) - ib_groups=" + ib_groups=( tag_string_artist Artist tag_string_copyright Copyright tag_string_character Character tag_string_general General tag_string_meta Meta - " + ) case "${ib_mode}" in (l) @@ -92,17 +92,17 @@ case "${ib_board}" in ib_api="https://gelbooru.com" ib_url="https://gelbooru.com" - ib_ratings=" + ib_ratings=( safe safe general general sensitive sensitive questionable questionable explicit explicit - " + ) - ib_groups=" + ib_groups=( tags Tags - " + ) case "${ib_mode}" in (p) @@ -160,23 +160,23 @@ case "${ib_board}" in ib_api="https://iapi.sankakucomplex.com" ib_url="https://idol.sankakucomplex.com" - ib_ratings=" + ib_ratings=( s safe q questionable e explicit - " + ) - ib_groups=" - tags[]|select(.type==1)|.name Idol - tags[]|select(.type==2)|.name Studio - tags[]|select(.type==3)|.name Copyright - tags[]|select(.type==4)|.name Character - tags[]|select(.type==6)|.name Genre - tags[]|select(.type==5)|.name Set - tags[]|select(.type==0)|.name General - tags[]|select(.type==8)|.name Medium - tags[]|select(.type==9)|.name Meta - " + ib_groups=( + "tags[]|select(.type==1)|.name" Idol + "tags[]|select(.type==2)|.name" Studio + "tags[]|select(.type==3)|.name" Copyright + "tags[]|select(.type==4)|.name" Character + "tags[]|select(.type==6)|.name" Genre + "tags[]|select(.type==5)|.name" Set + "tags[]|select(.type==0)|.name" General + "tags[]|select(.type==8)|.name" Medium + "tags[]|select(.type==9)|.name" Meta + ) case "${ib_mode}" in (l) @@ -233,22 +233,22 @@ case "${ib_board}" in ib_api="https://sankakuapi.com" ib_url="https://chan.sankakucomplex.com" - ib_ratings=" + ib_ratings=( s safe q questionable e explicit - " + ) - ib_groups=" - tags[]|select(.type==1)|.tagName Artist - tags[]|select(.type==2)|.tagName Studio - tags[]|select(.type==3)|.tagName Copyright - tags[]|select(.type==4)|.tagName Character - tags[]|select(.type==5)|.tagName Genre - tags[]|select(.type==0)|.tagName General - tags[]|select(.type==8)|.tagName Medium - tags[]|select(.type==9)|.tagName Meta - " + ib_groups=( + "tags[]|select(.type==1)|.tagName" Artist + "tags[]|select(.type==2)|.tagName" Studio + "tags[]|select(.type==3)|.tagName" Copyright + "tags[]|select(.type==4)|.tagName" Character + "tags[]|select(.type==5)|.tagName" Genre + "tags[]|select(.type==0)|.tagName" General + "tags[]|select(.type==8)|.tagName" Medium + "tags[]|select(.type==9)|.tagName" Meta + ) case "${ib_mode}" in (l) @@ -311,15 +311,15 @@ case "${ib_board}" in ;; esac - ib_ratings=" + ib_ratings=( s safe q questionable e explicit - " + ) - ib_groups=" + ib_groups=( tags Tags - " + ) case "${ib_mode}" in (l) diff --git a/units/ib_date.sh b/units/ib_date.zsh index e674238..803a386 100644 --- a/units/ib_date.sh +++ b/units/ib_date.zsh @@ -2,14 +2,14 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${ib_created_at}" ] && [ "${ib_created_at}" != "null" ] +if [[ -n "${ib_created_at}" && "${ib_created_at}" != "null" ]] then - if [ -n "${ib_itzfield}" ] + if [[ -n "${ib_itzfield}" ]] then ib_created_at="$(printf "%s" "${ib_created_at}" | parameter ${ib_itzfield})" fi - if [ -n "${ib_idate}" ] + if [[ -n "${ib_idate}" ]] then ib_date_text="$(date -ud "${ib_created_at}" -D "${ib_idate}" +"%Y-%m-%d %H:%M")" else diff --git a/units/ib_file.sh b/units/ib_file.zsh index 4009f52..0dff7fb 100644 --- a/units/ib_file.sh +++ b/units/ib_file.zsh @@ -10,40 +10,40 @@ done ib_file="${cache}/${ib_hash}.json" dump="${dump} ${ib_file##*/}" -if [ -f "${ib_file}" ] && [ "${caching_mode}" != "none" ] +if [[ -f "${ib_file}" && "${caching_mode}" != "none" ]] then ib_ctime=$(date +%s) ib_mtime=$(stat -c %Y "${ib_file}") - if [ $((ib_ctime - ib_mtime)) -le $((caching_time - 15)) ] + if [[ $((ib_ctime - ib_mtime)) -le $((caching_time - 15)) ]] then rm -fr "${cache}/${ib_hash}.lock" return 0 fi fi -if [ -n "${ib_config}" ] +if [[ -n "${ib_config}" ]] then - . "${units}/ib_token.sh" + . "${units}/ib_token.zsh" - if [ -n "${output_text}" ] + if [[ -n "${output_text}" ]] then rm -fr "${cache}/${ib_hash}.lock" return 0 fi fi -if [ -n "${ib_limit}" ] +if [[ -n "${ib_limit}" ]] then ib_limit="${ib_dlimit}=${ib_limit}" fi -if [ -n "${ib_page}" ] +if [[ -n "${ib_page}" ]] then ib_page="${ib_dpage}=$((ib_page + ib_ioffset))" fi -if [ -n "${ib_query}" ] +if [[ -n "${ib_query}" ]] then ib_query="${ib_dquery}=${ib_query}" fi @@ -75,8 +75,8 @@ then next_offset=${inline_page:-0} - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" rm -fr "${ib_file}" "${cache}/${ib_hash}.lock" return 0 @@ -89,8 +89,8 @@ then notification_text="${output_text}" log_text="ib_file (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" rm -fr "${ib_file}" "${cache}/${ib_hash}.lock" return 0 @@ -98,14 +98,14 @@ fi if ! jq -e ".${ib_iarray}[0]|has(\"${ib_iid}\")" "${ib_file}" > /dev/null then - if [ -n "${inline_options}" ] && [ -n "${offset}" ] + if [[ -n "${inline_options}" && -n "${offset}" ]] then output_title="End of results" else output_title="No results found" fi - if [ -n "${inline_options}" ] + if [[ -n "${inline_options}" ]] then case "${ib_mode}" in (l) @@ -119,7 +119,7 @@ then ;; esac else - output_text="Try different post ID or MD5 hash" + output_text="Try different post ID or MD5 h.zsh" fi notification_text="${output_text}" diff --git a/units/ib_hash.sh b/units/ib_hash.zsh index 22bfe95..f579180 100644 --- a/units/ib_hash.sh +++ b/units/ib_hash.zsh @@ -4,15 +4,15 @@ ib_mode="p" -. "${units}/ib_config.sh" -. "${units}/ib_authconfig.sh" +. "${units}/ib_config.zsh" +. "${units}/ib_authconfig.zsh" ib_query="md5:${ib_post_md5}" ib_hash="$(printf "%s%s%s" "${user_id}" "${ib_board}" "${ib_post_md5}" | enhash)" -. "${units}/ib_file.sh" +. "${units}/ib_file.zsh" -if [ -z "${output_text}" ] +if [[ -z "${output_text}" ]] then ib_id="$(jq -r ".${ib_iarray}[0].${ib_iid}" "${ib_file}")" printf "<b>%s ID:</b> <code>%s</code>\n" "${ib_name}" "${ib_id}" >> "${ib_posts}" diff --git a/units/ib_lock.sh b/units/ib_lock.zsh index a8897bc..e80df6c 100644 --- a/units/ib_lock.sh +++ b/units/ib_lock.zsh @@ -7,6 +7,6 @@ do sleep 1 done -. "${units}/ib_auth.sh" +. "${units}/ib_auth.zsh" rm -fr "${user_config}_auth.lock" diff --git a/units/ib_meta.sh b/units/ib_meta.zsh index a845a25..0484b5e 100644 --- a/units/ib_meta.sh +++ b/units/ib_meta.zsh @@ -2,7 +2,7 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${ib_file_url}" ] && [ "${ib_file_url}" != "null" ] +if [[ -n "${ib_file_url}" && "${ib_file_url}" != "null" ]] then ib_sample_url="$(jq -r ".${ib_iarray}[${array_count}].${ib_isample}" "${ib_file}")" ib_preview_url="$(jq -r ".${ib_iarray}[${array_count}].${ib_ipreview}" "${ib_file}")" @@ -10,33 +10,33 @@ then ib_height="$(jq -r ".${ib_iarray}[${array_count}].${ib_iheight}" "${ib_file}")" ib_type="$(printf "%s" "${ib_file_url}" | eval ${ib_ifilename} | cut -d '.' -f 2)" - if [ "${ib_name}" = "Idol Complex" ] + if [[ "${ib_name}" = "Idol Complex" ]] then ib_file_url="https:${ib_file_url}" fi - if [ -z "${ib_sample_url}" ] || [ "${ib_sample_url}" = "null" ] + if [[ -z "${ib_sample_url}" || "${ib_sample_url}" = "null" ]] then ib_sample_url=${ib_file_url} - elif [ "${ib_name}" = "Idol Complex" ] + elif [[ "${ib_name}" = "Idol Complex" ]] then ib_sample_url="https:${ib_sample_url}" fi - if [ -z "${ib_preview_url}" ] || [ "${ib_preview_url}" = "null" ] + if [[ -z "${ib_preview_url}" || "${ib_preview_url}" = "null" ]] then ib_preview_url=${ib_error_url} - elif [ "${ib_name}" = "Idol Complex" ] || [ "${ib_name}" = "Sankaku Channel" ] + elif [[ "${ib_name}" = "Idol Complex" || "${ib_name}" = "Sankaku Channel" ]] then ib_preview_url="${ib_sample_url}" fi - if [ -n "${ib_width}" ] && [ "${ib_width}" != "null" ] && [ ${ib_width} -gt 0 ] + if [[ -n "${ib_width}" && "${ib_width}" != "null" && ${ib_width} -gt 0 ]] then ib_resolution_text="${ib_width}x${ib_height}" fi - if [ -n "${ib_type}" ] + if [[ -n "${ib_type}" ]] then ib_type_text="$(printf "%s" "${ib_type}" | tr '[:lower:]' '[:upper:]')" fi @@ -46,15 +46,15 @@ then ib_type="photo" ;; (gif) - . "${units}/ib_preview.sh" + . "${units}/ib_preview.zsh" ib_type="gif" ;; (mp4) - . "${units}/ib_preview.sh" + . "${units}/ib_preview.zsh" ib_type="video" ;; (zip | webm) - . "${units}/ib_sample.sh" + . "${units}/ib_sample.zsh" ;; (*) ib_sample_url="${ib_error_url}" @@ -74,30 +74,30 @@ else ib_type="photo" fi -if [ -n "${ib_file_size}" ] && [ "${ib_file_size}" != "null" ] && [ ${ib_file_size} -gt 0 ] +if [[ -n "${ib_file_size}" && "${ib_file_size}" != "null" && ${ib_file_size} -gt 0 ]] then - if [ ${ib_file_size} -gt 20971520 ] && [ "${ib_sample_url}" = "${ib_file_url}" ] + if [[ ${ib_file_size} -gt 20971520 && "${ib_sample_url}" = "${ib_file_url}" ]] then - . "${units}/ib_sample.sh" + . "${units}/ib_sample.zsh" fi unit_offset=0 - size_offset=1 + size_offset=1.0 for unit in B KiB MiB GiB TiB PiB do unit_offset=${size_offset} size_offset=$((size_offset * 1024)) - if [ ${ib_file_size} -lt ${size_offset} ] + if [[ ${ib_file_size} -lt ${size_offset} ]] then break fi done - if [ ${ib_file_size} -ge 1024 ] + if [[ ${ib_file_size} -ge 1024 ]] then - ib_size_text="$(printf "%.2f %s" "$(printf "%s" "${ib_file_size} / ${unit_offset}" | bc -l)" "${unit}")" + ib_size_text="$(printf "%.2f %s" "$((ib_file_size / unit_offset))" "${unit}")" else ib_size_text="$(printf "%u %s" "${ib_file_size}" "${unit}")" fi diff --git a/units/ib_name.sh b/units/ib_name.zsh index cd5f180..c6a0e16 100644 --- a/units/ib_name.sh +++ b/units/ib_name.zsh @@ -4,31 +4,31 @@ board_table="a d g i k s y" -if [ -z "${1}" ] +if [[ -z "${1}" ]] then reply_text="$(jq -r '.message.reply_to_message.text' "${update}")" - if [ "${reply_text}" = "null" ] + if [[ "${reply_text}" = "null" ]] then reply_text="$(jq -r '.message.reply_to_message.caption' "${update}")" fi - if [ "${reply_text}" != "null" ] + 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 ${board_table} do - . "${units}/ib_config.sh" + . "${units}/ib_config.zsh" - if [ "${ib_reply_name}" = "${ib_name}" ] + if [[ "${ib_reply_name}" = "${ib_name}" ]] then break fi done - if [ "${ib_name}" = "Idol Complex" ] && echo "${reply_text}" | grep -q 'MD5' + if [[ "${ib_name}" = "Idol Complex" ]] && echo "${reply_text}" | grep -q 'MD5' then ib_post_id="$(printf "%s" "${reply_text}" | grep 'MD5' | parameter 2)" fi diff --git a/units/ib_original.sh b/units/ib_original.zsh index 1f2fbf1..6229bba 100644 --- a/units/ib_original.sh +++ b/units/ib_original.zsh @@ -5,19 +5,19 @@ ib_file_size="$(jq -r ".${ib_iarray}[0].${ib_isize}" "${ib_file}")" ib_file_url="$(jq -r ".${ib_iarray}[0].${ib_ifile}" "${ib_file}")" -. "${units}/ib_size.sh" +. "${units}/ib_size.zsh" -if [ -n "${ib_file_url}" ] && [ "${ib_file_url}" != "null" ] +if [[ -n "${ib_file_url}" && "${ib_file_url}" != "null" ]] then - . "${units}/ib_meta.sh" + . "${units}/ib_meta.zsh" else output_text="No original file found" return 0 fi -if [ -n "${ib_file_size}" ] && [ "${ib_file_size}" != "null" ] && [ ${ib_file_size} -gt 0 ] +if [[ -n "${ib_file_size}" && "${ib_file_size}" != "null" && ${ib_file_size} -gt 0 ]] then - if [ ${ib_file_size} -gt 20971520 ] + if [[ ${ib_file_size} -gt 20971520 ]] then output_text="File size is too large" fi diff --git a/units/ib_post.sh b/units/ib_post.zsh index af85126..ad8a5a0 100644 --- a/units/ib_post.sh +++ b/units/ib_post.zsh @@ -11,81 +11,72 @@ ib_parent_id="$(jq -r ".${ib_iarray}[0].${ib_iparent}" "${ib_file}")" ib_has_children="$(jq -r ".${ib_iarray}[0].${ib_ichildren}" "${ib_file}")" ib_md5="$(jq -r ".${ib_iarray}[0].${ib_imd5}" "${ib_file}")" ib_source="$(jq -r ".${ib_iarray}[0].${ib_isource}" "${ib_file}" | htmlescape)" -ib_tags="$(jq -r ".${ib_iarray}[0].${ib_itags}" "${ib_file}")" -ib_tags_count=0 +ib_tags=($(jq -r ".${ib_iarray}[0].${ib_itags}" "${ib_file}")) -. "${units}/ib_date.sh" -. "${units}/ib_size.sh" -. "${units}/ib_meta.sh" +. "${units}/ib_date.zsh" +. "${units}/ib_size.zsh" +. "${units}/ib_meta.zsh" output_text="$(printf "<b>%s</b>\n<b>ID:</b> <code>%s</code>" "${ib_name}" "${ib_id}")" -if [ -n "${ib_date_text}" ] +if [[ -n "${ib_date_text}" ]] then output_text="$(printf "%s\n<b>Date:</b> <code>%s</code>" "${output_text}" "${ib_date_text}")" fi -if [ -n "${ib_resolution_text}" ] +if [[ -n "${ib_resolution_text}" ]] then output_text="$(printf "%s\n<b>Resolution:</b> %s" "${output_text}" "${ib_resolution_text}")" fi -if [ -n "${ib_size_text}" ] +if [[ -n "${ib_size_text}" ]] then output_text="$(printf "%s\n<b>Size:</b> %s" "${output_text}" "${ib_size_text}")" fi -if [ -n "${ib_type_text}" ] +if [[ -n "${ib_type_text}" ]] then output_text="$(printf "%s\n<b>Type:</b> %s" "${output_text}" "${ib_type_text}")" fi -if [ -n "${ib_rating}" ] && [ "${ib_rating}" != "null" ] +if [[ -n "${ib_rating}" && "${ib_rating}" != "null" ]] then - set -- ${ib_ratings} - - while [ ${#} -ge 2 ] + while [[ ${#ib_ratings} -ge 2 ]] do - if [ "${ib_rating}" = "${1}" ] + if [[ "${ib_rating}" = "${ib_ratings[1]}" ]] then - output_text="$(printf "%s\n<b>Rating:</b> <code>%s</code>" "${output_text}" "${2}")" + output_text="$(printf "%s\n<b>Rating:</b> <code>%s</code>" "${output_text}" "${ib_ratings[2]}")" break else - shift 2 + ib_ratings=(${ib_ratings[@]:2}) fi done fi -if [ -n "${ib_parent_id}" ] && [ "${ib_parent_id}" != "null" ] && [ "${ib_parent_id}" != "0" ] +if [[ -n "${ib_parent_id}" && "${ib_parent_id}" != "null" && "${ib_parent_id}" != "0" ]] then output_text="$(printf "%s\n<b>Parent ID:</b> <code>%s</code>" "${output_text}" "${ib_parent_id}")" fi -if [ "${ib_has_children}" = "true" ] +if [[ "${ib_has_children}" = "true" ]] then output_text="$(printf "%s\n<b>Has children:</b> yes" "${output_text}")" fi -if [ -n "${ib_md5}" ] && [ "${ib_md5}" != "null" ] +if [[ -n "${ib_md5}" && "${ib_md5}" != "null" ]] then output_text="$(printf "%s\n<b>MD5:</b> <code>%s</code>" "${output_text}" "${ib_md5}")" fi -if [ -n "${ib_source}" ] && [ "${ib_source}" != "null" ] +if [[ -n "${ib_source}" && "${ib_source}" != "null" ]] then if echo "${ib_source}" | grep -q -e "pixiv" -e "pximg" then ib_source="https://www.pixiv.net/artworks/$(printf "%s" "${ib_source##*/}" | cut -d '_' -f 1)" fi - if [ ${#ib_source} -le 2048 ] + if [[ ${#ib_source} -le 2048 ]] then output_text="$(printf "%s\n<b>Source:</b> %s" "${output_text}" "${ib_source}")" fi fi - -if [ -n "${ib_tags}" ] && [ "${ib_tags}" != "null" ] -then - set -- ${ib_tags} - ib_tags_count=${#} -fi diff --git a/units/ib_preview.sh b/units/ib_preview.zsh index b44a54c..ab70e87 100644 --- a/units/ib_preview.sh +++ b/units/ib_preview.zsh @@ -2,7 +2,7 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ "${ib_preview_url}" = "${ib_sample_url}" ] +if [[ "${ib_preview_url}" = "${ib_sample_url}" ]] then ib_preview_url="${ib_error_url}" ib_width="${ib_error_width}" diff --git a/units/ib_sample.sh b/units/ib_sample.zsh index 4e4ee94..4dede5c 100644 --- a/units/ib_sample.sh +++ b/units/ib_sample.zsh @@ -2,7 +2,7 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ "${ib_preview_url}" = "${ib_sample_url}" ] +if [[ "${ib_preview_url}" = "${ib_sample_url}" ]] then ib_preview_url="${ib_error_url}" ib_width="${ib_error_width}" diff --git a/units/ib_search.sh b/units/ib_search.zsh index 9013e2f..075da44 100644 --- a/units/ib_search.sh +++ b/units/ib_search.zsh @@ -2,14 +2,14 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${1}" ] +if [[ -n "${1}" ]] then ib_board="${1}" - . "${units}/ib_config.sh" - . "${units}/ib_authconfig.sh" + . "${units}/ib_config.zsh" + . "${units}/ib_authconfig.zsh" - if [ -z "${ib_data_url}" ] + if [[ -z "${ib_data_url}" ]] then output_title="Invalid arguments" output_text="Unsupported image board" @@ -34,43 +34,29 @@ else set -- -a ${@} fi -if [ -n "${offset}" ] +if [[ -n "${offset}" ]] then inline_page=${offset} fi -if [ -n "${1}" ] +if [[ -n "${1}" ]] then inline_query="${@}" - while getopts ${inline_options} inline_getopts - do - case "${inline_getopts}" in - (a) - ib_autopaging=0 - ;; - (m) - ib_metadata=0 - ;; - (p) - ib_preview=0 - ;; - (q) - ib_quick=0 - ;; - (*) - output_title="Invalid arguments" - output_text="Unsupported options" - - return 0 - ;; - esac - done + if ! zparseopts -D -F -K -- \ + a=ib_autopaging \ + m=ib_metadata \ + p=ib_preview \ + q=ib_quick + then + output_title="Invalid arguments" + output_text="Unsupported options" - shift $((OPTIND - 1)) + return 0 + fi fi -if [ -n "${1}" ] +if [[ -n "${1}" ]] then ib_query="${@}" shift ${#} @@ -79,10 +65,10 @@ fi ib_limit=${inline_limit} ib_page=${inline_page} -if [ -n "${ib_iwildcard}" ] +if [[ -n "${ib_iwildcard}" ]] then ib_query="$(printf "%s" "${ib_query}" | sed "s/${ib_iwildcard}/\\\\${ib_iwildcard}/g" | tr '*' "${ib_iwildcard}")" fi ib_hash="$(printf "%s%s%s%s%s" "${user_id}" "${ib_mode}" "${ib_board}" "${ib_page}" "${ib_query}" | enhash)" -. "${units}/ib_file.sh" +. "${units}/ib_file.zsh" diff --git a/units/ib_size.sh b/units/ib_size.zsh index 9859e95..c9ef020 100644 --- a/units/ib_size.sh +++ b/units/ib_size.zsh @@ -2,12 +2,12 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${ib_file_size}" ] && [ "${ib_file_size}" != "null" ] +if [[ -n "${ib_file_size}" && "${ib_file_size}" != "null" ]] then return 0 fi -if [ -z "${ib_file_url}" ] || [ "${ib_file_url}" = "null" ] +if [[ -z "${ib_file_url}" || "${ib_file_url}" = "null" ]] then return 0 fi diff --git a/units/ib_token.sh b/units/ib_token.zsh index 03f2abd..e5d3c14 100644 --- a/units/ib_token.sh +++ b/units/ib_token.zsh @@ -7,19 +7,19 @@ do sleep 1 done -if [ -f "${user_config}/${ib_config}/legacy" ] +if [[ -f "${user_config}/${ib_config}/legacy" ]] then . "${user_config}/${ib_config}/legacy" fi -if [ -f "${user_config}/${ib_config}/timestamp" ] +if [[ -f "${user_config}/${ib_config}/timestamp" ]] then ib_ctime=$(date +%s) ib_mtime=$(cat "${user_config}/${ib_config}/timestamp") - if [ $((ib_ctime - ib_mtime)) -gt ${ib_expire} ] + if [[ $((ib_ctime - ib_mtime)) -gt ${ib_expire} ]] then - if [ -n "${ib_lock}" ] + if [[ -n "${ib_lock}" ]] then . "${units}/ib_lock.sh" & @@ -27,12 +27,12 @@ then output_text="Try again in a few seconds" notification_text="${output_title} ${output_text}" else - . "${units}/ib_auth.sh" + . "${units}/ib_auth.zsh" fi fi fi -if [ -f "${user_config}/${ib_config}/token" ] +if [[ -f "${user_config}/${ib_config}/token" ]] then ib_header="${ib_authorization} $(cat "${user_config}/${ib_config}/token")" fi diff --git a/units/log.sh b/units/log.zsh index 145b82f..2e5b972 100644 --- a/units/log.sh +++ b/units/log.zsh @@ -2,7 +2,7 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${no_logs}" ] +if [[ -n "${no_logs}" ]] then return 0 fi diff --git a/units/shorts_search.sh b/units/shorts_search.sh deleted file mode 100644 index 427c935..0000000 --- a/units/shorts_search.sh +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright (C) 2024-2025 Maria Lisina -# Copyright (C) 2024-2025 Danil Lisin -# SPDX-License-Identifier: Apache-2.0 - -if test "${1}" -gt 0 -then - inline_page=${1} - shift -else - inline_page=1 - set -- -a ${@} -fi - -if [ -n "${offset}" ] -then - inline_page=${offset} -fi - -if [ -n "${1}" ] -then - inline_query="${@}" - - while getopts "aqrw" inline_getopts - do - case "${inline_getopts}" in - (a) - shorts_autopaging=0 - ;; - (q) - shorts_quick=0 - ;; - (r) - shorts_reverse=0 - ;; - (w) - shorts_word=0 - ;; - (*) - output_title="Invalid arguments" - output_text="Unsupported options" - - return 0 - ;; - esac - done - - shift $((OPTIND - 1)) -fi - -if [ -n "${1}" ] -then - shorts_query="${@}" - shift ${#} -fi - -if [ -d "${short_config}" ] -then - if [ -n "${shorts_reverse}" ] - then - shorts_ls="-xtr" - else - shorts_ls="-xt" - fi - - shorts="$(ls ${shorts_ls} "${short_config}")" -fi - -set -- ${shorts} - -if [ ${#} -eq 0 ] -then - output_title="No shortcuts found" - output_text="You have no saved shortcuts yet" - - return 0 -fi - -if [ -n "${shorts_query}" ] -then - if [ -n "${shorts_word}" ] - then - shorts_grep="-lqwFe" - else - shorts_grep="-lqiFe" - fi - - for short in ${@} - do - if grep ${shorts_grep} "${shorts_query}" "${short_config}/${short}" - then - query_shorts="${query_shorts} ${short}" - fi - done - - set -- ${query_shorts} -fi - -if [ ${#} -ge $(((inline_page - 1) * inline_limit + 1)) ] -then - shift $(((inline_page - 1) * inline_limit)) -else - if [ -n "${offset}" ] - then - output_title="End of results" - else - output_title="No results found" - fi - - output_text="Try different page or query" -fi diff --git a/units/shorts_search.zsh b/units/shorts_search.zsh new file mode 100644 index 0000000..9d98d34 --- /dev/null +++ b/units/shorts_search.zsh @@ -0,0 +1,94 @@ +# Copyright (C) 2024-2025 Maria Lisina +# Copyright (C) 2024-2025 Danil Lisin +# SPDX-License-Identifier: Apache-2.0 + +if test "${1}" -gt 0 +then + inline_page=${1} + shift +else + inline_page=1 + set -- -a ${@} +fi + +if [[ -n "${offset}" ]] +then + inline_page=${offset} +fi + +if [[ -n "${1}" ]] +then + inline_query="${@}" + + if ! zparseopts -D -F -K -- \ + a=shorts_autopaging \ + q=shorts_quick \ + r=shorts_reverse \ + w=shorts_word + then + output_title="Invalid arguments" + output_text="Unsupported options" + + return 0 + fi +fi + +if [[ -n "${1}" ]] +then + shorts_query="${@}" + shift ${#} +fi + +if [[ -d "${short_config}" ]] +then + if [[ -n "${shorts_reverse}" ]] + then + shorts_ls="-xtr" + else + shorts_ls="-xt" + fi + + shorts=($(ls ${shorts_ls} "${short_config}")) +fi + +if [[ ${#shorts} -eq 0 ]] +then + output_title="No shortcuts found" + output_text="You have no saved shortcuts yet" + + return 0 +fi + +if [[ -n "${shorts_query}" ]] +then + if [[ -n "${shorts_word}" ]] + then + shorts_grep="-lqwFe" + else + shorts_grep="-lqiFe" + fi + + for short in ${shorts[@]} + do + if grep ${shorts_grep} "${shorts_query}" "${short_config}/${short}" + then + query_shorts=(${query_shorts[@]} ${short}) + fi + done + + shorts=(${query_shorts[@]}) +fi + +if [[ ${#shorts} -ge $(((inline_page - 1) * inline_limit + 1)) ]] +then + shorts=(${shorts[@]:$(((inline_page - 1) * inline_limit))}) +else + if [[ -n "${offset}" ]] + then + output_title="End of results" + else + output_title="No results found" + fi + + output_text="Try different page or query" +fi diff --git a/units/sn_auth.sh b/units/sn_auth.zsh index 8bf8fc3..e441224 100644 --- a/units/sn_auth.sh +++ b/units/sn_auth.zsh @@ -2,10 +2,10 @@ # Copyright (C) 2024-2025 Danil Lisin # SPDX-License-Identifier: Apache-2.0 -if [ -n "${1}" ] +if [[ -n "${1}" ]] then sn_key="${1}" -elif [ -f "${user_config}/saucenao" ] +elif [[ -f "${user_config}/saucenao" ]] then sn_key="$(cat "${user_config}/saucenao")" return 0 @@ -30,8 +30,8 @@ then output_text="Failed to process request" log_text="sn_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -41,19 +41,19 @@ then output_text="An unknown error occurred" log_text="sn_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi -if [ "$(jq -r '.header.user_id' "${sn_file}")" = "null" ] +if [[ "$(jq -r '.header.user_id' "${sn_file}")" = "null" ]] then output_text="Invalid API Key" log_text="sn_auth (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi diff --git a/units/sn_get.sh b/units/sn_get.zsh index 0adb1f7..d47658a 100644 --- a/units/sn_get.sh +++ b/units/sn_get.zsh @@ -5,13 +5,13 @@ message_id="$(jq -r '.message.reply_to_message.message_id' "${update}")" file_id="$(jq -r '.message.reply_to_message.photo.[1].file_id' "${update}")" -if [ "${message_id}" = "null" ] || [ "${message_id}" = "${message_thread_id}" ] +if [[ "${message_id}" = "null" || "${message_id}" = "${message_thread_id}" ]] then output_text="You must use this command in reply to an image" return 0 fi -if [ "${file_id}" = "null" ] +if [[ "${file_id}" = "null" ]] then output_text="Could not find an image in replied message" return 0 @@ -32,8 +32,8 @@ then output_text="Failed to get the image file" log_text="getFile (${update_id}): Failed to access Telegram Bot API" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -43,42 +43,42 @@ then output_text="An unknown error occurred" log_text="getFile (${update_id}): An unknown error occurred" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi -if [ "$(jq -r '.ok' "${output_file}")" != "true" ] +if [[ "$(jq -r '.ok' "${output_file}")" != "true" ]] then output_text="Failed to get the image file" error_description="$(jq -r '.description' "${output_file}")" - if [ "${error_description}" != "null" ] + if [[ "${error_description}" != "null" ]] then log_text="getFile (${update_id}): ${error_description}" else log_text="getFile (${update_id}): An unknown error occurred" fi - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi file_path="$(jq -r '.result.file_path' "${output_file}")" -if [ "${api_address}" = "${local_address}" ] && ! ls "${file_path}" > /dev/null +if [[ "${api_address}" = "${local_address}" ]] && ! ls "${file_path}" > /dev/null then output_text="There is an error on the bot side, please contact bot deployer" log_text="Error: sn_get: Cannot access Telegram Bot API working directory" - . "${units}/log.sh" + . "${units}/log.zsh" return 0 fi -if [ "${api_address}" = "${default_address}" ] +if [[ "${api_address}" = "${default_address}" ]] then output_file="${cache}/${update_id}_file.jpg" dump="${dump} ${output_file##*/}" @@ -93,26 +93,26 @@ then output_text="Failed to download the image file" log_text="getFile (${update_id}): Failed to access Telegram Bot API" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi - if [ "$(jq -r '.ok' "${output_file}")" = "false" ] + if [[ "$(jq -r '.ok' "${output_file}")" = "false" ]] then output_text="Failed to download the image file" error_description="$(jq -r '.description' "${output_file}")" - if [ "${error_description}" != "null" ] + if [[ "${error_description}" != "null" ]] then log_text="getFile (${update_id}): ${error_description}" else log_text="getFile (${update_id}): An unknown error occurred" fi - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -121,4 +121,4 @@ then fi sn_query="file=@${file_path}" -. "${units}/sn_search.sh" +. "${units}/sn_search.zsh" diff --git a/units/sn_search.sh b/units/sn_search.zsh index bfdd047..2c6bd45 100644 --- a/units/sn_search.sh +++ b/units/sn_search.zsh @@ -26,8 +26,8 @@ then output_text="Failed to process request" log_text="sn_search (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi @@ -37,17 +37,17 @@ then output_text="An unknown error occurred" log_text="sn_search (${update_id}): ${output_text}" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" return 0 fi -if [ "$(jq -r '.header.status' "${sn_file}")" != "0" ] +if [[ "$(jq -r '.header.status' "${sn_file}")" != "0" ]] then output_text="Error: <code>$(jq -r '.header.message' "${sn_file}" | htmlescape)</code>" log_text="sn_search (${update_id}): $(jq -r '.header.message' "${sn_file}")" - . "${units}/log.sh" - . "${units}/dump.sh" + . "${units}/log.zsh" + . "${units}/dump.zsh" fi diff --git a/units/user.sh b/units/user.sh deleted file mode 100644 index 69c7dd7..0000000 --- a/units/user.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2024-2025 Maria Lisina -# Copyright (C) 2024-2025 Danil Lisin -# SPDX-License-Identifier: Apache-2.0 - -aliases="${files}/aliases.txt" -blacklist="${files}/blacklist.txt" -whitelist="${files}/whitelist.txt" - -positional_parameters="${@}" - -if [ -s "${aliases}" ] && alias="$(grep -x "${user_id} .*" "${aliases}")" -then - user_id="$(printf "%s" "${alias}" | parameter 2)" -fi - -if [ -s "${blacklist}" ] && grep -qx "${user_id}" "${blacklist}" -then - exit 0 -fi - -if [ -s "${whitelist}" ] && ! grep -qx "${user_id}" "${whitelist}" -then - exit 0 -fi - -user_config="${config}/${user_id}" -set -- ${positional_parameters} diff --git a/units/user.zsh b/units/user.zsh new file mode 100644 index 0000000..f861301 --- /dev/null +++ b/units/user.zsh @@ -0,0 +1,24 @@ +# Copyright (C) 2024-2025 Maria Lisina +# Copyright (C) 2024-2025 Danil Lisin +# SPDX-License-Identifier: Apache-2.0 + +aliases_file="${files}/aliases.txt" +blacklist_file="${files}/blacklist.txt" +whitelist_file="${files}/whitelist.txt" + +if [[ -s "${aliases_file}" ]] && alias="$(grep -x "${user_id} .*" "${aliases_file}")" +then + user_id="$(printf "%s" "${alias}" | parameter 2)" +fi + +if [[ -s "${blacklist_file}" ]] && grep -qx "${user_id}" "${blacklist_file}" +then + exit 0 +fi + +if [[ -s "${whitelist_file}" ]] && ! grep -qx "${user_id}" "${whitelist_file}" +then + exit 0 +fi + +user_config="${config}/${user_id}" |
