Attempt to fix the problems with the say plugin.

This commit is contained in:
Storm Dragon
2025-11-20 12:46:31 -05:00
parent d801547bb2
commit ab78bb6bb9

View File

@@ -28,38 +28,39 @@ if [[ "$channelName" == "$userName" ]]; then
firstArg="$1" firstArg="$1"
echo "DEBUG say.sh: PM context detected, firstArg='$firstArg'" >> "$log" echo "DEBUG say.sh: PM context detected, firstArg='$firstArg'" >> "$log"
# Check if first argument starts with # (explicit channel) # Note: bot.sh strips "# " from commands, so #channel becomes just channel name
# IRC channels can contain: alphanumeric, -, _, and some special chars # Check if first argument looks like a channel name (matches configured channels)
if [[ "$firstArg" =~ ^#[a-zA-Z0-9_-]+$ ]]; then isConnected=false
# Remove # prefix for comparison with configured channels targetChannel=""
targetChannel="${firstArg#\#}"
# Check if the bot is connected to this channel for configuredChannel in "${channels[@]}"; do
isConnected=false if [[ "$firstArg" == "$configuredChannel" ]]; then
for configuredChannel in "${channels[@]}"; do isConnected=true
if [[ "$configuredChannel" == "$targetChannel" ]]; then targetChannel="$configuredChannel"
isConnected=true break
break fi
fi done
done
if [[ "$isConnected" == "true" ]]; then if [[ "$isConnected" == "true" ]]; then
# Send message to specified channel # First arg is a known channel, send message there
shift shift
if [[ -z "$*" ]]; then if [[ -z "$*" ]]; then
msg "$userName" "Please provide a message to say in $firstArg." msg "$userName" "Please provide a message to say in #$targetChannel."
else
msg "$firstArg" "$*"
fi
else else
# Not connected to that channel msg "#$targetChannel" "$*"
msg "$userName" "I am not connected to $firstArg."
fi fi
else else
# No channel specified or doesn't start with #, broadcast to all channels # Check if first arg looks like it could be a channel name (not in our list)
for configuredChannel in "${channels[@]}"; do # If it contains no spaces and looks channel-ish, assume user specified wrong channel
msg "#$configuredChannel" "$*" if [[ "$firstArg" =~ ^[a-zA-Z0-9_-]+$ ]] && [[ ! "$firstArg" =~ [[:space:]] ]]; then
done # Looks like a channel name but we're not connected
msg "$userName" "I am not connected to #$firstArg."
else
# No channel specified, broadcast to all channels
for configuredChannel in "${channels[@]}"; do
msg "#$configuredChannel" "$*"
done
fi
fi fi
else else
# Channel context: just say the message in the current channel # Channel context: just say the message in the current channel