From fc5726a4f12feecdc617cbdf02d61940ce62cff4 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Thu, 20 Nov 2025 13:07:08 -0500 Subject: [PATCH] Hopefully fixed weird bug where it was using the message sender as the channel to check. --- modules/say/say.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/say/say.sh b/modules/say/say.sh index 6766234..41a52f5 100755 --- a/modules/say/say.sh +++ b/modules/say/say.sh @@ -25,19 +25,20 @@ fi # Check if invoked from a PM (channel name equals username) if [[ "$channelName" == "$userName" ]]; then # PM context: check if first argument is a channel name - firstArg="$1" - echo "DEBUG say.sh: PM context detected, firstArg='$firstArg'" >> "$log" + # Extract just the first word (bot.sh passes all remaining args as a single string) + firstWord="${1%% *}" + echo "DEBUG say.sh: PM context detected, firstWord='$firstWord', allArgs='$*'" >> "$log" # Note: bot.sh strips "# " (hash-space) from commands, but "#channel" stays intact # Remove # prefix if present for comparison - firstArgNoHash="${firstArg#\#}" + firstWordNoHash="${firstWord#\#}" - # Check if first argument looks like a channel name (matches configured channels) + # Check if first word looks like a channel name (matches configured channels) isConnected=false targetChannel="" for configuredChannel in "${channels[@]}"; do - if [[ "$firstArgNoHash" == "$configuredChannel" ]]; then + if [[ "$firstWordNoHash" == "$configuredChannel" ]]; then isConnected=true targetChannel="$configuredChannel" break @@ -45,19 +46,20 @@ if [[ "$channelName" == "$userName" ]]; then done if [[ "$isConnected" == "true" ]]; then - # First arg is a known channel, send message there - shift - if [[ -z "$*" ]]; then + # First word is a known channel, extract the rest as the message + restOfMessage="${1#* }" + # If firstWord == $1, there was no space, so no message + if [[ "$firstWord" == "$1" ]]; then msg "$userName" "Please provide a message to say in #$targetChannel." else - msg "#$targetChannel" "$*" + msg "#$targetChannel" "$restOfMessage" fi else - # Check if first arg looks like it could be a channel name (not in our list) + # Check if first word looks like it could be a channel name (not in our list) # If it contains no spaces and looks channel-ish, assume user specified wrong channel - if [[ "$firstArgNoHash" =~ ^[a-zA-Z0-9_-]+$ ]] && [[ ! "$firstArgNoHash" =~ [[:space:]] ]]; then + if [[ "$firstWordNoHash" =~ ^[a-zA-Z0-9_-]+$ ]] && [[ ! "$firstWordNoHash" =~ [[:space:]] ]]; then # Looks like a channel name but we're not connected - msg "$userName" "I am not connected to #$firstArgNoHash." + msg "$userName" "I am not connected to #$firstWordNoHash." else # No channel specified, broadcast to all channels for configuredChannel in "${channels[@]}"; do