Fixed a bug with irc parsing.
This commit is contained in:
5
bot.sh
5
bot.sh
@@ -267,6 +267,11 @@ while true; do
|
||||
;;
|
||||
# run when a message is seen
|
||||
*PRIVMSG*)
|
||||
# Only process if this is a user message (contains ! for hostmask)
|
||||
if [[ ! "$result" =~ :[^!]+!.*PRIVMSG ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
who="${result%%!*}"
|
||||
who="${who:1}"
|
||||
from="${result#*#}"
|
||||
|
||||
@@ -12,6 +12,18 @@ channelName="$2"
|
||||
shift 2
|
||||
message="$*"
|
||||
|
||||
# Sanitize username (extract just the nickname, max 30 chars per IRC RFC)
|
||||
# Remove any IRC protocol remnants, hostmask info, etc.
|
||||
name="${name%%!*}" # Remove hostmask if present
|
||||
name="${name%%[[:space:]]*}" # Remove any trailing data
|
||||
name="${name//[^a-zA-Z0-9_\[\]\{\}\\|\^-]/}" # Only allow valid IRC nick chars
|
||||
name="${name:0:30}" # Limit to max IRC nickname length
|
||||
|
||||
# If name is empty or invalid after sanitization, skip
|
||||
if [[ -z "$name" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Sanitize channel name (remove any IRC protocol remnants)
|
||||
channelName="${channelName%%[[:space:]]*}"
|
||||
channelName="${channelName//[^a-zA-Z0-9#_-]/}"
|
||||
|
||||
Reference in New Issue
Block a user