From 8ae2995413cf405f4acd701f650ee7613b742650 Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Thu, 17 Apr 2025 23:13:25 +0200 Subject: [PATCH] new to command to enter chat --- src/meshcore_cli/meshcore_cli.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index 283997f..941122a 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -48,14 +48,17 @@ async def subscribe_to_msgs(mc): CS = mc.subscribe(EventType.CHANNEL_MSG_RECV, handle_message) 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. Use \"to\" to selects contact, \"list\" to list contacts, \"send\" to send a message ... Line starting with \"$\" or \".\" will issue a meshcli command. \"quit\" or \"q\" will end interactive mode""") 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: while True: @@ -750,6 +753,13 @@ async def next_cmd(mc, cmds, json_output=False): await subscribe_to_msgs(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" | "@" : argnum = 1 res = await mc.commands.send_cli(cmds[1])