From 5e749af65be14b20111787026cd83c85ccbb04ec Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 1 Feb 2026 13:31:25 -0500 Subject: [PATCH] ignoreList and allowList now array format. Should make things a little more sane. --- bot.cfg.example | 9 ++++++--- bot.sh | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/bot.cfg.example b/bot.cfg.example index d729513..1c46764 100644 --- a/bot.cfg.example +++ b/bot.cfg.example @@ -27,9 +27,12 @@ autoRejoinChannel=true curseKicker=true # Symbols used to specify you are calling a bot module. botCaller=",.!+?" -# People who are allowed to private message the bot separate multiple names with | -allowList="" -ignoreList="storm_bot" +# People who are allowed to private message the bot +# Add multiple names like: allowList=("name1" "name2" "name3") +allowList=() +# People who should be ignored (no greetings, keywords, or word tracking) +# Add multiple names like: ignoreList=("name1" "name2" "name3") +ignoreList=("storm_bot") # Interval in seconds to send PING to server for connection health check (default: 120) # Set to 0 to disable proactive ping checks (not recommended) pingInterval=120 diff --git a/bot.sh b/bot.sh index 94b4009..8f5fd92 100755 --- a/bot.sh +++ b/bot.sh @@ -70,10 +70,8 @@ for i in "bot.cfg" "functions.sh" ; do done # Variables important to modules need to be exported here. -export allowList export channels export input -export ignoreList export nick export quitMessage export intentionalExit @@ -111,7 +109,28 @@ rm_input() { is_ignored() { local nick="$1" - [[ -n "$ignoreList" && "$nick" =~ ^($ignoreList)$ ]] + local ignoreName + + for ignoreName in "${ignoreList[@]}"; do + if [[ "$nick" == "$ignoreName" ]]; then + return 0 + fi + done + + return 1 +} + +is_allowed() { + local nick="$1" + local allowedName + + for allowedName in "${allowList[@]}"; do + if [[ "$nick" == "$allowedName" ]]; then + return 0 + fi + done + + return 1 } # Function to stop ping monitor process @@ -266,8 +285,14 @@ while true; do originalNick="${result#:}" originalNick="${originalNick%%!*}" # If the old nick was in the ignore list, update it. - if [[ "${originalNick}" =~ ^($ignoreList)$ ]]; then - export ignoreList="${ignoreList/${originalNick}/${result#:*:}}" + if is_ignored "$originalNick"; then + newNick="${result#:*:}" + for ignoreIndex in "${!ignoreList[@]}"; do + if [[ "${ignoreList[ignoreIndex]}" == "$originalNick" ]]; then + ignoreList[ignoreIndex]="$newNick" + break + fi + done fi ;; # respond to ping requests from the server @@ -356,7 +381,7 @@ while true; do command="${command//# /}" will="${command#* }" command="${command%% *}" - if [[ "$from" =~ ^($allowList)$ ]]; then + if is_allowed "$from"; then if command -v "./modules/${command% *}/${command% *}.sh" ; then willSanitized="${will//[$'\001'-$'\037'$'\177']/}" echo "Calling module ./modules/${command% *}/${command% *}/${command% *}.sh \"$who\" \"$from\" $willSanitized" >> "$log" @@ -425,7 +450,7 @@ while true; do ./modules/say/say.sh "$who" "$from" "$who: $(shuf -n1 "response/error.txt")" fi else - if ! [[ "$who" =~ ^($ignoreList)$ ]]; then + if ! is_ignored "$who"; then set -f ./triggers/keywords/keywords.sh "$who" "$from" "$result" # Only call wordtrack for valid channel messages