From 7f29d4d2ca5c178d9718c89d1408f455d48f6a6b Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 19 Jun 2025 10:19:30 +0200 Subject: [PATCH 1/4] make space before bot command optional `bot:build ...` or `bot: build` should both work just fine, no reason to require a hard space in between --- tools/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/commands.py b/tools/commands.py index 5db8f7f7..1909c0bf 100644 --- a/tools/commands.py +++ b/tools/commands.py @@ -46,7 +46,7 @@ def get_bot_command(line): fn = sys._getframe().f_code.co_name log(f"{fn}(): searching for bot command in '{line}'") - match = re.search('^bot: (.*)$', line) + match = re.search('^bot:( )?(.*)$', line) # TODO add log messages for both cases if match: return match.group(1).rstrip() From 66005da564cb1aba73d1716c51b5c2fa202a70d2 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 19 Jun 2025 12:04:24 +0200 Subject: [PATCH 2/4] fix regex for bot build command + add log messages --- tools/commands.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/commands.py b/tools/commands.py index 1909c0bf..0982df12 100644 --- a/tools/commands.py +++ b/tools/commands.py @@ -46,11 +46,13 @@ def get_bot_command(line): fn = sys._getframe().f_code.co_name log(f"{fn}(): searching for bot command in '{line}'") - match = re.search('^bot:( )?(.*)$', line) - # TODO add log messages for both cases + match = re.search('^bot:[ ]?(.*)$', line) if match: - return match.group(1).rstrip() + cmd = match.group(1).rstrip() + log(f"Bot command found in '{line}': {cmd}") + return cmd else: + log(f"No bot command found using pattern '{match.pattern}' in: {line}") return None From 02c24659416407a7c3499c85306eaadee7f1addb Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 19 Jun 2025 19:05:22 +0200 Subject: [PATCH 3/4] fix logging with regex pattern in get_bot_command --- tools/commands.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/commands.py b/tools/commands.py index 0982df12..5fb411c4 100644 --- a/tools/commands.py +++ b/tools/commands.py @@ -46,13 +46,14 @@ def get_bot_command(line): fn = sys._getframe().f_code.co_name log(f"{fn}(): searching for bot command in '{line}'") - match = re.search('^bot:[ ]?(.*)$', line) + regex = re.compile('^bot:[ ]?(.*)$') + match = regex.search(line) if match: cmd = match.group(1).rstrip() log(f"Bot command found in '{line}': {cmd}") return cmd else: - log(f"No bot command found using pattern '{match.pattern}' in: {line}") + log(f"No bot command found using pattern '{regex.pattern}' in: {line}") return None From 8eec372bd03a0bd568fd0d2c1a45b927eb1ad5e5 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 19 Jun 2025 19:06:47 +0200 Subject: [PATCH 4/4] mention function name in log message in get_bot_command --- tools/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/commands.py b/tools/commands.py index 5fb411c4..b842cc19 100644 --- a/tools/commands.py +++ b/tools/commands.py @@ -50,10 +50,10 @@ def get_bot_command(line): match = regex.search(line) if match: cmd = match.group(1).rstrip() - log(f"Bot command found in '{line}': {cmd}") + log(f"{fn}(): Bot command found in '{line}': {cmd}") return cmd else: - log(f"No bot command found using pattern '{regex.pattern}' in: {line}") + log(f"{fn}(): No bot command found using pattern '{regex.pattern}' in: {line}") return None