ignoreList and allowList now array format. Should make things a little more sane.

This commit is contained in:
Storm Dragon
2026-02-01 13:31:25 -05:00
parent dc222c7aab
commit 5e749af65b
2 changed files with 38 additions and 10 deletions

View File

@@ -27,9 +27,12 @@ autoRejoinChannel=true
curseKicker=true curseKicker=true
# Symbols used to specify you are calling a bot module. # Symbols used to specify you are calling a bot module.
botCaller=",.!+?" botCaller=",.!+?"
# People who are allowed to private message the bot separate multiple names with | # People who are allowed to private message the bot
allowList="" # Add multiple names like: allowList=("name1" "name2" "name3")
ignoreList="storm_bot" 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) # Interval in seconds to send PING to server for connection health check (default: 120)
# Set to 0 to disable proactive ping checks (not recommended) # Set to 0 to disable proactive ping checks (not recommended)
pingInterval=120 pingInterval=120

39
bot.sh
View File

@@ -70,10 +70,8 @@ for i in "bot.cfg" "functions.sh" ; do
done done
# Variables important to modules need to be exported here. # Variables important to modules need to be exported here.
export allowList
export channels export channels
export input export input
export ignoreList
export nick export nick
export quitMessage export quitMessage
export intentionalExit export intentionalExit
@@ -111,7 +109,28 @@ rm_input() {
is_ignored() { is_ignored() {
local nick="$1" 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 # Function to stop ping monitor process
@@ -266,8 +285,14 @@ while true; do
originalNick="${result#:}" originalNick="${result#:}"
originalNick="${originalNick%%!*}" originalNick="${originalNick%%!*}"
# If the old nick was in the ignore list, update it. # If the old nick was in the ignore list, update it.
if [[ "${originalNick}" =~ ^($ignoreList)$ ]]; then if is_ignored "$originalNick"; then
export ignoreList="${ignoreList/${originalNick}/${result#:*:}}" newNick="${result#:*:}"
for ignoreIndex in "${!ignoreList[@]}"; do
if [[ "${ignoreList[ignoreIndex]}" == "$originalNick" ]]; then
ignoreList[ignoreIndex]="$newNick"
break
fi
done
fi fi
;; ;;
# respond to ping requests from the server # respond to ping requests from the server
@@ -356,7 +381,7 @@ while true; do
command="${command//# /}" command="${command//# /}"
will="${command#* }" will="${command#* }"
command="${command%% *}" command="${command%% *}"
if [[ "$from" =~ ^($allowList)$ ]]; then if is_allowed "$from"; then
if command -v "./modules/${command% *}/${command% *}.sh" ; then if command -v "./modules/${command% *}/${command% *}.sh" ; then
willSanitized="${will//[$'\001'-$'\037'$'\177']/}" willSanitized="${will//[$'\001'-$'\037'$'\177']/}"
echo "Calling module ./modules/${command% *}/${command% *}/${command% *}.sh \"$who\" \"$from\" $willSanitized" >> "$log" 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")" ./modules/say/say.sh "$who" "$from" "$who: $(shuf -n1 "response/error.txt")"
fi fi
else else
if ! [[ "$who" =~ ^($ignoreList)$ ]]; then if ! is_ignored "$who"; then
set -f set -f
./triggers/keywords/keywords.sh "$who" "$from" "$result" ./triggers/keywords/keywords.sh "$who" "$from" "$result"
# Only call wordtrack for valid channel messages # Only call wordtrack for valid channel messages