aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md28
-rwxr-xr-xaliases.zsh174
-rwxr-xr-xblacklist.zsh149
-rwxr-xr-xwhitelist.zsh149
4 files changed, 28 insertions, 472 deletions
diff --git a/README.md b/README.md
index 37e3abe..6eb80b7 100644
--- a/README.md
+++ b/README.md
@@ -88,6 +88,34 @@ Simply copy desired data from your user directory to `users/0`
| `yandere` | Yandere |
| `saucenao` | SauceNAO |
+### Users access management
+
+You can configure whitelist, blacklist and aliases to let only specific users have access to bot, block specific users from accessing bot or let specific users have full access to other user data respectively
+
+It is recommended to manage them only after you ran bot at least once
+
+#### Blacklist and Whitelist
+
+One-column list
+
+```
+777000
+1087968824
+```
+
+Simply place user IDs following this example
+
+#### Aliases
+
+Two-columns list
+
+```
+777000 1087968824
+```
+
+In this example `777000` is aliased to `1087968824`, instead of own user directory `777000` uses `1087968824` directory with full access
+
+This is useful when you have multiple accounts and want to share same data across them
## Supported Image Boards
diff --git a/aliases.zsh b/aliases.zsh
deleted file mode 100755
index 4103e0a..0000000
--- a/aliases.zsh
+++ /dev/null
@@ -1,174 +0,0 @@
-#!/usr/bin/env zsh
-#
-# Copyright (C) 2024-2026 Maria Lisina
-# Copyright (C) 2024-2026 Danil Lisin
-# SPDX-License-Identifier: Apache-2.0
-
-if [[ "${__aliases_env}" != "0" ]]
-then
- env -i PATH="${PATH}" __aliases_env=0 "${0}" ${@}
- exit ${?}
-fi
-
-exec 2> /dev/null
-
-set -e
-umask 77
-
-dir="${0%/*}"
-files="${dir}/files"
-list="${files}/aliases.txt"
-
-if [[ -n "${1}" ]]
-then
- action="${1}"
-
- case "${action}" in
- (help)
- help=0
- ;;
- (list | add | del | reset)
- ;;
- (*)
- echo "Unrecognized action ${action}" \
- "\nSee '${0} help'"
- exit 1
- ;;
- esac
-
- shift
-else
- help=0
-fi
-
-if [[ -n "${help}" ]]
-then
- echo "Aliases Manager" \
- "\n\nUsage: ${0} [action] [ID] [alias ID]" \
- "\n\nActions:" \
- "\n help\t\tShow help information" \
- "\n list\t\tList all aliases" \
- "\n add\t\tAdd user ID alias" \
- "\n del\t\tRemove user ID alias" \
- "\n reset\t\tRemove all aliases"
- exit 0
-fi
-
-for module in zsh/files
-do
- if ! zmodload ${module}
- then
- failed="${failed} ${module}"
- fi
-done
-
-if [[ -n "${failed}" ]]
-then
- echo "Failed to load Z Shell modules:${failed}" \
- "\nUpdate your Z Shell or get a version with all required modules"
- exit 1
-fi
-
-for required in busybox
-do
- if ! command -v ${required} > /dev/null
- then
- missing="${missing} ${required}"
- fi
-done
-
-if [[ -n "${missing}" ]]
-then
- echo "Missing dependencies:${missing}" \
- "\nFor more information follow: https://command-not-found.com/"
- exit 1
-fi
-
-for function in cut grep sed
-do
- if busybox ${function} --help > /dev/null
- then
- alias ${function}="busybox ${function}"
- else
- missing="${missing} ${function}"
- fi
-done
-
-if [[ -n "${missing}" ]]
-then
- echo "Missing BusyBox functions:${missing}" \
- "\nUpdate your BusyBox or get a version with all required functions"
- exit 1
-fi
-
-case "${action}" in
- (add | del)
- if [[ -n "${1}" ]]
- then
- user_id="${1}"
-
- if ! test ${user_id} -gt 0
- then
- echo "Illegal user ID ${user_id}"
- exit 1
- fi
-
- shift
- else
- echo "You must specify target user ID" \
- "\nSee '${0} help'"
- exit 1
- fi
- ;;
-esac
-
-if ! [[ -f "${list}" ]]
-then
- < "${list}.default" > "${list}"
-fi
-
-case "${action}" in
- (list)
- list=($(< "${list}"))
-
- while [[ ${#list} -ge 2 ]]
- do
- printf "%s --> %s\n" "${list[1]}" "${list[2]}"
- shift 2 list
- done
- ;;
- (add)
- if [[ -n "${1}" ]]
- then
- alias_id="${1}"
-
- if ! test ${alias_id} -gt 0
- then
- echo "Illegal user ID ${alias_id}"
- exit 1
- fi
-
- shift
- else
- echo "You must specify alias ID" \
- "\nSee '${0} help'"
- exit 1
- fi
-
- if alias="$(grep -x "${user_id} .*" "${list}")"
- then
- alias_id="$(cut -F 2 <<< "${alias}")"
-
- echo "User ID ${user_id} is already aliased to ${alias_id}"
- exit 1
- fi
-
- printf "%s %s\n" "${user_id}" "${alias_id}" >> "${list}"
- ;;
- (del)
- sed -i "/^${user_id} .*$/d" "${list}"
- ;;
- (reset)
- < "${list}.default" > "${list}"
- ;;
-esac
diff --git a/blacklist.zsh b/blacklist.zsh
deleted file mode 100755
index d7efbc8..0000000
--- a/blacklist.zsh
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/bin/env zsh
-#
-# Copyright (C) 2024-2026 Maria Lisina
-# Copyright (C) 2024-2026 Danil Lisin
-# SPDX-License-Identifier: Apache-2.0
-
-if [[ "${__blacklist_env}" != "0" ]]
-then
- env -i PATH="${PATH}" __blacklist_env=0 "${0}" ${@}
- exit ${?}
-fi
-
-exec 2> /dev/null
-
-set -e
-umask 77
-
-dir="${0%/*}"
-files="${dir}/files"
-list="${files}/blacklist.txt"
-
-if [[ -n "${1}" ]]
-then
- action="${1}"
-
- case "${action}" in
- (help)
- help=0
- ;;
- (list | add | del | reset)
- ;;
- (*)
- echo "Unrecognized action ${action}" \
- "\nSee '${0} help'"
- exit 1
- ;;
- esac
-
- shift
-else
- help=0
-fi
-
-if [[ -n "${help}" ]]
-then
- echo "Blacklist Manager" \
- "\n\nUsage: ${0} [action] [ID]" \
- "\n\nActions:" \
- "\n help\t\tShow help information" \
- "\n list\t\tList blacklist entries" \
- "\n add\t\tAdd user ID to blacklist" \
- "\n del\t\tRemove user ID from blacklist" \
- "\n reset\t\tRemove all blacklist entries"
- exit 0
-fi
-
-for module in zsh/files
-do
- if ! zmodload ${module}
- then
- failed="${failed} ${module}"
- fi
-done
-
-if [[ -n "${failed}" ]]
-then
- echo "Failed to load Z Shell modules:${failed}" \
- "\nUpdate your Z Shell or get a version with all required modules"
- exit 1
-fi
-
-for required in busybox
-do
- if ! command -v ${required} > /dev/null
- then
- missing="${missing} ${required}"
- fi
-done
-
-if [[ -n "${missing}" ]]
-then
- echo "Missing dependencies:${missing}" \
- "\nFor more information follow: https://command-not-found.com/"
- exit 1
-fi
-
-for function in grep sed
-do
- if busybox ${function} --help > /dev/null
- then
- alias ${function}="busybox ${function}"
- else
- missing="${missing} ${function}"
- fi
-done
-
-if [[ -n "${missing}" ]]
-then
- echo "Missing BusyBox functions:${missing}" \
- "\nUpdate your BusyBox or get a version with all required functions"
- exit 1
-fi
-
-case "${action}" in
- (add | del)
- if [[ -n "${1}" ]]
- then
- user_id="${1}"
-
- if ! test ${user_id} -gt 0
- then
- echo "Illegal user ID ${user_id}"
- exit 1
- fi
-
- shift
- else
- echo "You must specify user ID" \
- "\nSee '${0} help'"
- exit 1
- fi
- ;;
-esac
-
-if ! [[ -f "${list}" ]]
-then
- < "${list}.default" > "${list}"
-fi
-
-case "${action}" in
- (list)
- < "${list}"
- ;;
- (add)
- if grep -qx "${user_id}" "${list}"
- then
- echo "User ID ${user_id} is already in blacklist"
- exit 1
- fi
-
- printf "%s\n" "${user_id}" >> "${list}"
- ;;
- (del)
- sed -i "/^${user_id}$/d" "${list}"
- ;;
- (reset)
- < "${list}.default" > "${list}"
- ;;
-esac
diff --git a/whitelist.zsh b/whitelist.zsh
deleted file mode 100755
index e418765..0000000
--- a/whitelist.zsh
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/bin/env zsh
-#
-# Copyright (C) 2024-2026 Maria Lisina
-# Copyright (C) 2024-2026 Danil Lisin
-# SPDX-License-Identifier: Apache-2.0
-
-if [[ "${__whitelist_env}" != "0" ]]
-then
- env -i PATH="${PATH}" __whitelist_env=0 "${0}" ${@}
- exit ${?}
-fi
-
-exec 2> /dev/null
-
-set -e
-umask 77
-
-dir="${0%/*}"
-files="${dir}/files"
-list="${files}/whitelist.txt"
-
-if [[ -n "${1}" ]]
-then
- action="${1}"
-
- case "${action}" in
- (help)
- help=0
- ;;
- (list | add | del | reset)
- ;;
- (*)
- echo "Unrecognized action ${action}" \
- "\nSee '${0} help'"
- exit 1
- ;;
- esac
-
- shift
-else
- help=0
-fi
-
-if [[ -n "${help}" ]]
-then
- echo "Whitelist Manager" \
- "\n\nUsage: ${0} [action] [ID]" \
- "\n\nActions:" \
- "\n help\t\tShow help information" \
- "\n list\t\tList whitelist entries" \
- "\n add\t\tAdd user ID to whitelist" \
- "\n del\t\tRemove user ID from whitelist" \
- "\n reset\t\tRemove all whitelist entries"
- exit 0
-fi
-
-for module in zsh/files
-do
- if ! zmodload ${module}
- then
- failed="${failed} ${module}"
- fi
-done
-
-if [[ -n "${failed}" ]]
-then
- echo "Failed to load Z Shell modules:${failed}" \
- "\nUpdate your Z Shell or get a version with all required modules"
- exit 1
-fi
-
-for required in busybox
-do
- if ! command -v ${required} > /dev/null
- then
- missing="${missing} ${required}"
- fi
-done
-
-if [[ -n "${missing}" ]]
-then
- echo "Missing dependencies:${missing}" \
- "\nFor more information follow: https://command-not-found.com/"
- exit 1
-fi
-
-for function in grep sed
-do
- if busybox ${function} --help > /dev/null
- then
- alias ${function}="busybox ${function}"
- else
- missing="${missing} ${function}"
- fi
-done
-
-if [[ -n "${missing}" ]]
-then
- echo "Missing BusyBox functions:${missing}" \
- "\nUpdate your BusyBox or get a version with all required functions"
- exit 1
-fi
-
-case "${action}" in
- (add | del)
- if [[ -n "${1}" ]]
- then
- user_id="${1}"
-
- if ! test ${user_id} -gt 0
- then
- echo "Illegal user ID ${user_id}"
- exit 1
- fi
-
- shift
- else
- echo "You must specify user ID" \
- "\nSee '${0} help'"
- exit 1
- fi
- ;;
-esac
-
-if ! [[ -f "${list}" ]]
-then
- < "${list}.default" > "${list}"
-fi
-
-case "${action}" in
- (list)
- < "${list}"
- ;;
- (add)
- if grep -qx "${user_id}" "${list}"
- then
- echo "User ID ${user_id} is already in whitelist"
- exit 1
- fi
-
- printf "%s\n" "${user_id}" >> "${list}"
- ;;
- (del)
- sed -i "/^${user_id}$/d" "${list}"
- ;;
- (reset)
- < "${list}.default" > "${list}"
- ;;
-esac