From d32baa66ba7ea902599820d36fd6a15ff14f79ac Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 25 Oct 2025 01:38:14 -0400 Subject: [PATCH] Fixed a bug with irc parsing. --- bot.sh | 5 +++++ triggers/wordtrack/wordtrack.sh | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/bot.sh b/bot.sh index c237b4c..3b625d9 100755 --- a/bot.sh +++ b/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#*#}" diff --git a/triggers/wordtrack/wordtrack.sh b/triggers/wordtrack/wordtrack.sh index acefb94..4afc941 100755 --- a/triggers/wordtrack/wordtrack.sh +++ b/triggers/wordtrack/wordtrack.sh @@ -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#_-]/}"