mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
special error treatment for setperm in chat mode
This commit is contained in:
parent
3839ad8a50
commit
49ee83b94d
1 changed files with 24 additions and 21 deletions
|
|
@ -779,28 +779,31 @@ Line starting with \"$\" or \".\" will issue a meshcli command.
|
||||||
# special treatment for setperm to support contact name as param
|
# special treatment for setperm to support contact name as param
|
||||||
elif contact["type"] > 1 and\
|
elif contact["type"] > 1 and\
|
||||||
(line.startswith("setperm ") or line.startswith("set perm ")):
|
(line.startswith("setperm ") or line.startswith("set perm ")):
|
||||||
cmds = shlex.split(line)
|
try:
|
||||||
off = 1 if line.startswith("set perm") else 0
|
cmds = shlex.split(line)
|
||||||
name = cmds[1 + off]
|
off = 1 if line.startswith("set perm") else 0
|
||||||
perm_string = cmds[2 + off]
|
name = cmds[1 + off]
|
||||||
if (perm_string.startswith("0x")):
|
perm_string = cmds[2 + off]
|
||||||
perm = int(perm_string,0)
|
if (perm_string.startswith("0x")):
|
||||||
elif (perm_string.startswith("#")):
|
perm = int(perm_string,0)
|
||||||
perm = int(perm_string[1:])
|
elif (perm_string.startswith("#")):
|
||||||
else:
|
perm = int(perm_string[1:])
|
||||||
perm = int(perm_string,16)
|
|
||||||
ct=mc.get_contact_by_name(name)
|
|
||||||
if ct is None:
|
|
||||||
ct=mc.get_contact_by_key_prefix(name)
|
|
||||||
if ct is None:
|
|
||||||
if name == "self" or mc.self_info["public_key"].startswith(name):
|
|
||||||
key = mc.self_info["public_key"]
|
|
||||||
else:
|
else:
|
||||||
key = name
|
perm = int(perm_string,16)
|
||||||
else:
|
ct=mc.get_contact_by_name(name)
|
||||||
key=ct["public_key"]
|
if ct is None:
|
||||||
newline=f"setperm {key} {perm}"
|
ct=mc.get_contact_by_key_prefix(name)
|
||||||
await process_cmds(mc, ["cmd", contact["adv_name"], newline])
|
if ct is None:
|
||||||
|
if name == "self" or mc.self_info["public_key"].startswith(name):
|
||||||
|
key = mc.self_info["public_key"]
|
||||||
|
else:
|
||||||
|
key = name
|
||||||
|
else:
|
||||||
|
key=ct["public_key"]
|
||||||
|
newline=f"setperm {key} {perm}"
|
||||||
|
await process_cmds(mc, ["cmd", contact["adv_name"], newline])
|
||||||
|
except IndexError:
|
||||||
|
print("Wrong number of parameters")
|
||||||
|
|
||||||
# same but for commands with a parameter
|
# same but for commands with a parameter
|
||||||
elif contact["type"] > 0 and (line.startswith("cmd ") or\
|
elif contact["type"] > 0 and (line.startswith("cmd ") or\
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue