From ac82eeb905cb044bbb0174b3a6be9ced5e9aa1f8 Mon Sep 17 00:00:00 2001 From: Florent Date: Sun, 1 Feb 2026 09:25:44 -0400 Subject: [PATCH] hashtag is not mandatory anymore in scope names --- src/meshcore/commands/messaging.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/meshcore/commands/messaging.py b/src/meshcore/commands/messaging.py index c48e50c..e6ae9a4 100644 --- a/src/meshcore/commands/messaging.py +++ b/src/meshcore/commands/messaging.py @@ -235,13 +235,20 @@ class MessagingCommands(CommandHandlerBase): return await self.send(cmd_data, [EventType.MSG_SENT, EventType.ERROR]) async def set_flood_scope(self, scope): - if scope.startswith("#"): # an hash - logger.debug(f"Setting scope from hash {scope}") - scope_key = sha256(scope.encode("utf-8")).digest()[0:16] - elif scope == "0" or scope == "None" or scope == "*" or scope == "": # disable + + if scope is None: + logger.debug(f"Resetting scope") scope_key = b"\0"*16 - else: # assume the key has been sent directly - scope_key = scope.encode("utf-8") + elif isinstance (scope, str): + if scope == "0" or scope == "None" or scope == "*" or scope == "": # disable + logger.debug(f"Resetting scope") + scope_key = b"\0"*16 + else: + logger.debug(f"Setting scope from string {scope}") + scope_key = sha256(scope.encode("utf-8")).digest()[0:16] + elif isinstance (scope, bytes): # scope has been sent directly as byte + logger.debug(f"Directly setting scope to {scope}") + scope_key = scope logger.debug(f"Setting scope to {scope_key.hex()}")