diff --git a/dougbot/core/command_parser.py b/dougbot/core/command_parser.py index 0e3bb7b..050dfdb 100644 --- a/dougbot/core/command_parser.py +++ b/dougbot/core/command_parser.py @@ -57,7 +57,7 @@ class CommandParser: ] CRAFT_PATTERNS = [ - r"(?:craft|make|build|create)\s+(?:a\s+|an\s+|some\s+|me\s+)?(\w+)", + r"(?:craft|make|build|create)\s+(.+)", ] MINE_PATTERNS = [ @@ -165,9 +165,23 @@ class CommandParser: for pattern in self.CRAFT_PATTERNS: match = re.search(pattern, msg, re.IGNORECASE) if match: - item = match.group(1).strip() if match.lastindex else "" - # Normalize item name - item = item.replace(" ", "_").lower() + raw_item = match.group(1).strip() if match.lastindex else "" + # Extract item name: take first 1-3 non-filler words before any preposition + filler = {"a", "an", "some", "me", "the", "this", "that", "please"} + stop_words = {"with", "from", "using", "in", "on", "at", "for", "out", "of"} + words = [] + for w in raw_item.split(): + wl = w.lower().rstrip(".,!?") + if wl in filler: + continue + if wl in stop_words: + break # Stop at prepositions + words.append(wl) + if len(words) >= 3: + break + if not words: + return None + item = "_".join(words) return ParsedCommand( action="craft", target=item,