mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
new to command to enter chat
This commit is contained in:
parent
4324967b2b
commit
8ae2995413
1 changed files with 12 additions and 2 deletions
|
|
@ -48,14 +48,17 @@ async def subscribe_to_msgs(mc):
|
||||||
CS = mc.subscribe(EventType.CHANNEL_MSG_RECV, handle_message)
|
CS = mc.subscribe(EventType.CHANNEL_MSG_RECV, handle_message)
|
||||||
await mc.start_auto_message_fetching()
|
await mc.start_auto_message_fetching()
|
||||||
|
|
||||||
async def interactive_loop(mc) :
|
async def interactive_loop(mc, to=None) :
|
||||||
print("""Interactive mode, most commands from terminal chat should work.
|
print("""Interactive mode, most commands from terminal chat should work.
|
||||||
Use \"to\" to selects contact, \"list\" to list contacts, \"send\" to send a message ...
|
Use \"to\" to selects contact, \"list\" to list contacts, \"send\" to send a message ...
|
||||||
Line starting with \"$\" or \".\" will issue a meshcli command.
|
Line starting with \"$\" or \".\" will issue a meshcli command.
|
||||||
\"quit\" or \"q\" will end interactive mode""")
|
\"quit\" or \"q\" will end interactive mode""")
|
||||||
|
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
contact = next(iter(mc.contacts.items()))[1]
|
if to is None:
|
||||||
|
contact = next(iter(mc.contacts.items()))[1]
|
||||||
|
else:
|
||||||
|
contact = to
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -750,6 +753,13 @@ async def next_cmd(mc, cmds, json_output=False):
|
||||||
await subscribe_to_msgs(mc)
|
await subscribe_to_msgs(mc)
|
||||||
await interactive_loop(mc)
|
await interactive_loop(mc)
|
||||||
|
|
||||||
|
case "chat_to" | "to" :
|
||||||
|
argnum = 1
|
||||||
|
await mc.ensure_contacts()
|
||||||
|
contact = mc.get_contact_by_name(cmds[1])
|
||||||
|
await subscribe_to_msgs(mc)
|
||||||
|
await interactive_loop(mc, to=contact)
|
||||||
|
|
||||||
case "cli" | "@" :
|
case "cli" | "@" :
|
||||||
argnum = 1
|
argnum = 1
|
||||||
res = await mc.commands.send_cli(cmds[1])
|
res = await mc.commands.send_cli(cmds[1])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue