mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
hashtag is not mandatory anymore in scope names
This commit is contained in:
parent
a2d8b3e059
commit
ac82eeb905
1 changed files with 13 additions and 6 deletions
|
|
@ -235,13 +235,20 @@ class MessagingCommands(CommandHandlerBase):
|
||||||
return await self.send(cmd_data, [EventType.MSG_SENT, EventType.ERROR])
|
return await self.send(cmd_data, [EventType.MSG_SENT, EventType.ERROR])
|
||||||
|
|
||||||
async def set_flood_scope(self, scope):
|
async def set_flood_scope(self, scope):
|
||||||
if scope.startswith("#"): # an hash
|
|
||||||
logger.debug(f"Setting scope from hash {scope}")
|
if scope is None:
|
||||||
scope_key = sha256(scope.encode("utf-8")).digest()[0:16]
|
logger.debug(f"Resetting scope")
|
||||||
elif scope == "0" or scope == "None" or scope == "*" or scope == "": # disable
|
|
||||||
scope_key = b"\0"*16
|
scope_key = b"\0"*16
|
||||||
else: # assume the key has been sent directly
|
elif isinstance (scope, str):
|
||||||
scope_key = scope.encode("utf-8")
|
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()}")
|
logger.debug(f"Setting scope to {scope_key.hex()}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue