Skip to content

Commit b8096dd

Browse files
committed
add sleep command to at (sleeps after command)
1 parent 72793de commit b8096dd

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/meshcore_cli/meshcore_cli.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,29 @@ async def process_contact_chat_line(mc, contact, line):
10711071
print("")
10721072
return True
10731073

1074+
if line.startswith("sleep") or line.startswith("s"):
1075+
try:
1076+
sleeptime = int(line.split(" ",2)[1])
1077+
cmd_pos = 2
1078+
except IndexError: # nothing arg after sleep
1079+
sleeptime = 1
1080+
cmd_pos = 0
1081+
except ValueError:
1082+
sleeptime = 1
1083+
cmd_pos = 1
1084+
1085+
try:
1086+
if cmd_pos > 0:
1087+
secline = line.split(" ",cmd_pos)[cmd_pos]
1088+
await process_contact_chat_line(mc, contact, secline)
1089+
except IndexError:
1090+
pass
1091+
1092+
# will sleep after executed command if there is a command
1093+
await asyncio.sleep(sleeptime)
1094+
1095+
return True
1096+
10741097
if line == "contact_lastmod":
10751098
timestamp = contact["lastmod"]
10761099
print(f"{contact['adv_name']} updated"
@@ -3174,7 +3197,7 @@ def get_help_for (cmdname, context="line") :
31743197
- d, direct, similar to h>-1
31753198
- f, flood, similar to h<0 or h=-1
31763199
3177-
Note: Some commands like contact_name (aka cn), reset_path (aka rp), forget_password (aka fp) can be chained.
3200+
Note: Some commands like contact_name (aka cn), reset_path (aka rp), forget_password (aka fp) can be chained. There is also a sleep command taking an optional event. The sleep will be issued after the command, it helps limiting rate through repeaters ...
31783201
31793202
Examples:
31803203
# removes all clients that have not been updated in last 2 days

0 commit comments

Comments
 (0)