From 0c1c587bc764c17d5d3258a0a6ea0cd2a40412f6 Mon Sep 17 00:00:00 2001 From: Nestpebble Date: Fri, 27 Sep 2024 01:26:01 +0100 Subject: [PATCH 1/6] strip ! from tonode, cos its copied by default on the android app. --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 81e2ac1..9301016 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -478,7 +478,7 @@ def handle_bbspost(message, message_from_id, deviceID): return "example: bbspost $subject #message" elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] - toNode = toNode.rstrip() + toNode = toNode.rstrip().strip("!") if toNode.isalpha() or not toNode.isnumeric(): toNode = get_num_from_short_name(toNode, deviceID) if toNode == 0: From 0b101d662e794274be28e8e2ca90b8e3a948c418 Mon Sep 17 00:00:00 2001 From: Nestpebble Date: Fri, 27 Sep 2024 02:26:55 +0100 Subject: [PATCH 2/6] trying to simplify nodeid entry... --- mesh_bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 9301016..d975fbb 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -478,8 +478,10 @@ def handle_bbspost(message, message_from_id, deviceID): return "example: bbspost $subject #message" elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] - toNode = toNode.rstrip().strip("!") - if toNode.isalpha() or not toNode.isnumeric(): + toNode = toNode.rstrip() + if "!" in toNode and toNode.strip("!").ishex(): + toNode = toNode.strip("!") + elif toNode.isalpha() or not toNode.isnumeric(): toNode = get_num_from_short_name(toNode, deviceID) if toNode == 0: return "Node not found " + message.split("@")[1].split("#")[0] From f23c4e2b6a44496f76392f4b31f71c81a1605f82 Mon Sep 17 00:00:00 2001 From: Nestpebble Date: Fri, 27 Sep 2024 02:29:58 +0100 Subject: [PATCH 3/6] sdf --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index d975fbb..95ce04e 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -479,7 +479,7 @@ def handle_bbspost(message, message_from_id, deviceID): elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] toNode = toNode.rstrip() - if "!" in toNode and toNode.strip("!").ishex(): + if "!" in toNode and toNode.strip("!").isHex(): toNode = toNode.strip("!") elif toNode.isalpha() or not toNode.isnumeric(): toNode = get_num_from_short_name(toNode, deviceID) From 55472bbbc082e29a24be5471aedc2ea5a4e8c5c4 Mon Sep 17 00:00:00 2001 From: Nestpebble Date: Fri, 27 Sep 2024 03:12:40 +0100 Subject: [PATCH 4/6] try this --- mesh_bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 95ce04e..bc8ccbb 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -479,8 +479,12 @@ def handle_bbspost(message, message_from_id, deviceID): elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] toNode = toNode.rstrip() - if "!" in toNode and toNode.strip("!").isHex(): - toNode = toNode.strip("!") + if "!" in toNode: + try: + int(toNode.strip("!"),16) + toNode = int(toNode.strip("!"),16) + except ValueError as e: + logger.debug("toNode is not hex, error: {e}") elif toNode.isalpha() or not toNode.isnumeric(): toNode = get_num_from_short_name(toNode, deviceID) if toNode == 0: From df5f648b26fc80f90420ffabe55ef5952a8554db Mon Sep 17 00:00:00 2001 From: Nestpebble Date: Fri, 27 Sep 2024 03:30:21 +0100 Subject: [PATCH 5/6] try and round off adding an interpreter to the bbs DM --- mesh_bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index bc8ccbb..932eaad 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -479,12 +479,13 @@ def handle_bbspost(message, message_from_id, deviceID): elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] toNode = toNode.rstrip() - if "!" in toNode: + # if toNode preceded by !, or is 8 characters long try to interpret as hex + if "!" in toNode or len(toNode) == 8: try: - int(toNode.strip("!"),16) toNode = int(toNode.strip("!"),16) except ValueError as e: logger.debug("toNode is not hex, error: {e}") + # if toNode is all alpha or not totally numeric, see if it is a shortname elif toNode.isalpha() or not toNode.isnumeric(): toNode = get_num_from_short_name(toNode, deviceID) if toNode == 0: From b4af552fb9202aac6a77b751149f0001c264487d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 26 Sep 2024 20:55:32 -0700 Subject: [PATCH 6/6] Update mesh_bot.py --- mesh_bot.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 9849b8d..bbe303f 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -468,42 +468,43 @@ def handle_bbspost(message, message_from_id, deviceID): logger.info(f"System: BBS Post: {subject} Body: {body}") return bbs_post_message(subject, body, message_from_id) elif not "example:" in message: - return "example: bbspost $subject #message" + return "example: bbspost $subject #✉️message" elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] toNode = toNode.rstrip() - # if toNode preceded by !, or is 8 characters long try to interpret as hex - if "!" in toNode or len(toNode) == 8: + if toNode.startswith("!") and len(toNode) == 8: + # mesh !hex try: toNode = int(toNode.strip("!"),16) except ValueError as e: - logger.debug("toNode is not hex, error: {e}") - # if toNode is all alpha or not totally numeric, see if it is a shortname + toNode = 0 elif toNode.isalpha() or not toNode.isnumeric(): + # try short name toNode = get_num_from_short_name(toNode, deviceID) + + if "#" in message: if toNode == 0: return "Node not found " + message.split("@")[1].split("#")[0] - if "#" in message: body = message.split("#")[1] return bbs_post_dm(toNode, body, message_from_id) else: - return "example: bbspost @nodeNumber/ShortName #message" + return "example: bbspost @nodeNumber/ShortName/!hex #✉️message" elif not "example:" in message: - return "example: bbspost $subject #message, or bbspost @node #message" + return "example: bbspost $subject #✉️message, or bbspost @node #✉️message" def handle_bbsread(message): if "#" in message and not "example:" in message: messageID = int(message.split("#")[1]) return bbs_read_message(messageID) elif not "example:" in message: - return "Please add a message number example: bbsread #14" + return "Please add a ✉️message number example: bbsread #14" def handle_bbsdelete(message, message_from_id): if "#" in message and not "example:" in message: messageID = int(message.split("#")[1]) return bbs_delete_message(messageID, message_from_id) elif not "example:" in message: - return "Please add a message number example: bbsdelete #14" + return "Please add a ✉️message number example: bbsdelete #14" def handle_messages(message, deviceID, channel_number, msg_history, publicChannel, isDM): if "?" in message and isDM: