diff --git a/main.py b/main.py index a50daad..882dfdb 100644 --- a/main.py +++ b/main.py @@ -11,15 +11,6 @@ from rules import ( RuleEngine, CommandContext, GlobalCooldownRule, - CooldownRule, - MaxUsageRule, - MinReactionsRule, - NotUserRule, - NotSameUserRule, - TimeWindowRule, - AndRule, - OrRule, - AlwaysPassRule, ) # Create FastAPI app @@ -178,7 +169,12 @@ async def scheduled_task(counter): counter.string_map = {} def extract_envelope_source_uuid(message): - """Extract sourceUuid from the raw message (for rule engine context).""" + """Extract sourceUuid from the raw JSON message string. + + Unlike extract_source_uuid() which works on parsed envelope data, + this function parses the raw message string and extracts from envelope. + Used to get user ID for the rule engine context. + """ message_json = json.loads(message) return message_json.get('envelope', {}).get('sourceUuid', '') diff --git a/rules.py b/rules.py index a2c9c32..3c93475 100644 --- a/rules.py +++ b/rules.py @@ -8,7 +8,7 @@ logical AND/OR operations. from abc import ABC, abstractmethod from datetime import datetime, time, timedelta -from typing import Optional, Dict, Any, List +from typing import Optional, Dict, Any, List, Iterable class CommandContext: @@ -307,7 +307,7 @@ class RuleEngine: """Set the rule for a specific command.""" self._command_rules[command] = rule - def set_command_rules(self, commands: tuple, rule: Rule): + def set_command_rules(self, commands: Iterable[str], rule: Rule): """Set the same rule for multiple commands.""" for command in commands: self._command_rules[command] = rule