More fixes. Nearly working.
This commit is contained in:
@@ -28,13 +28,16 @@ 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"
|
||||||
|
|
||||||
# Note: bot.sh strips "# " from commands, so #channel becomes just channel name
|
# Note: bot.sh strips "# " (hash-space) from commands, but "#channel" stays intact
|
||||||
|
# Remove # prefix if present for comparison
|
||||||
|
firstArgNoHash="${firstArg#\#}"
|
||||||
|
|
||||||
# Check if first argument looks like a channel name (matches configured channels)
|
# Check if first argument looks like a channel name (matches configured channels)
|
||||||
isConnected=false
|
isConnected=false
|
||||||
targetChannel=""
|
targetChannel=""
|
||||||
|
|
||||||
for configuredChannel in "${channels[@]}"; do
|
for configuredChannel in "${channels[@]}"; do
|
||||||
if [[ "$firstArg" == "$configuredChannel" ]]; then
|
if [[ "$firstArgNoHash" == "$configuredChannel" ]]; then
|
||||||
isConnected=true
|
isConnected=true
|
||||||
targetChannel="$configuredChannel"
|
targetChannel="$configuredChannel"
|
||||||
break
|
break
|
||||||
@@ -52,9 +55,9 @@ if [[ "$channelName" == "$userName" ]]; then
|
|||||||
else
|
else
|
||||||
# Check if first arg looks like it could be a channel name (not in our list)
|
# Check if first arg 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 it contains no spaces and looks channel-ish, assume user specified wrong channel
|
||||||
if [[ "$firstArg" =~ ^[a-zA-Z0-9_-]+$ ]] && [[ ! "$firstArg" =~ [[:space:]] ]]; then
|
if [[ "$firstArgNoHash" =~ ^[a-zA-Z0-9_-]+$ ]] && [[ ! "$firstArgNoHash" =~ [[:space:]] ]]; then
|
||||||
# Looks like a channel name but we're not connected
|
# Looks like a channel name but we're not connected
|
||||||
msg "$userName" "I am not connected to #$firstArg."
|
msg "$userName" "I am not connected to #$firstArgNoHash."
|
||||||
else
|
else
|
||||||
# No channel specified, broadcast to all channels
|
# No channel specified, broadcast to all channels
|
||||||
for configuredChannel in "${channels[@]}"; do
|
for configuredChannel in "${channels[@]}"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user