diff --git a/python/signal_bot/main.py b/python/signal_bot/main.py index 9574130..ecb7f19 100644 --- a/python/signal_bot/main.py +++ b/python/signal_bot/main.py @@ -24,11 +24,11 @@ logger = logging.getLogger(__name__) HELP_TEXT = ( "Available commands:\n" - " !inventory — update van inventory from a text list\n" - " !inventory (+ photo) — update van inventory from a receipt photo\n" - " !status — show bot status\n" - " !help — show this help message\n" - "Send a receipt photo with the message '!inventory' to scan it.\n" + " inventory — update van inventory from a text list\n" + " inventory (+ photo) — update van inventory from a receipt photo\n" + " status — show bot status\n" + " help — show this help message\n" + "Send a receipt photo with the message 'inventory' to scan it.\n" ) @@ -101,11 +101,12 @@ def dispatch( return text = message.message.strip() + parts = text.split() - prefix = config.cmd_prefix - if not text.startswith(prefix) and not message.attachments: + if not parts and not message.attachments: return - cmd = text.lstrip(prefix).split()[0].lower() if text.startswith(prefix) else "" + + cmd = parts[0].lower() if parts else "" commands = { "help": help_action, @@ -113,7 +114,14 @@ def dispatch( "inventory": inventory_action, } - action = commands.get(cmd, unknown_action) + action = commands.get(cmd) + if action is None: + if message.attachments: + action = inventory_action + cmd = "inventory" + else: + return + action(signal, message, llm, registry, config, cmd) diff --git a/python/signal_bot/models.py b/python/signal_bot/models.py index c9480b7..9cccab2 100644 --- a/python/signal_bot/models.py +++ b/python/signal_bot/models.py @@ -80,7 +80,6 @@ class BotConfig(BaseModel): phone_number: str inventory_api_url: str engine: Engine - cmd_prefix: str = "!" reconnect_delay: int = 5 max_reconnect_delay: int = 300 max_retries: int = 10