From 85585db7233508457d66b24bdfc1ec11180bf750 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 5 Aug 2024 23:20:44 -0700 Subject: [PATCH] enhance --- mesh_bot.py | 17 ++++++++++------- pong_bot.py | 15 +++++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index d5c7b74..b48d55b 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -103,7 +103,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi bot_response = bbs_list_messages() elif "bbspost" in message.lower(): # Check if the user added a subject to the message - if "$" in message: + if "$" in message and not "example:" in message: subject = message.split("$")[1].split("#")[0] subject = subject.rstrip() if "#" in message: @@ -114,7 +114,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi else: bot_response = "example: bbspost $subject #message" # Check if the user added a node number to the message - elif "@" in message: + elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] toNode = toNode.rstrip() if "#" in message: @@ -127,25 +127,28 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi elif "bbsread" in message.lower(): # Check if the user added a message number to the message - if "#" in message: + if "#" in message and not "example:" in message: messageID = int(message.split("#")[1]) bot_response = bbs_read_message(messageID) else: - bot_response = "Please add a message number ex: bbsread #14" + bot_response = "Please add a message number example: bbsread #14" elif "bbsdelete" in message.lower(): # Check if the user added a message number to the message - if "#" in message: + if "#" in message and not "example:" in message: messageID = int(message.split("#")[1]) bot_response = bbs_delete_message(messageID, message_from_id) else: - bot_response = "Please add a message number ex: bbsdelete #14" + bot_response = "Please add a message number example: bbsdelete #14" elif "ack" in message.lower(): if hop == "Direct": bot_response = "🏓ACK-ACK! " + f"SNR:{snr} RSSI:{rssi}" else: bot_response = "🏓ACK-ACK! " + hop elif "testing" in message.lower() or "test" in message.lower(): - bot_response = "🏓Testing 1,2,3" + if hop == "Direct": + bot_response = "🏓Testing 1,2,3 " + f"SNR:{snr} RSSI:{rssi}" + else: + bot_response = "🏓Testing 1,2,3 " + hop else: bot_response = "I'm sorry, I'm afraid I can't do that." diff --git a/pong_bot.py b/pong_bot.py index 5e99fc9..b8309ad 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -22,11 +22,6 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi bot_response = "🏓PONG, " + f"SNR:{snr} RSSI:{rssi}" else: bot_response = "🏓PONG, " + hop - elif "ack" in message.lower(): - if hop == "Direct": - bot_response = "🏓ACK-ACK! " + f"SNR:{snr} RSSI:{rssi}" - else: - bot_response = "🏓ACK-ACK! " + hop elif "pong" in message.lower(): bot_response = "🏓Ping!!" elif "motd" in message.lower(): @@ -48,8 +43,16 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi bot_response += "Port2:\n" + str(get_node_list(2)) chutil2 = interface2.nodes.get(decimal_to_hex(myNodeNum2), {}).get("deviceMetrics", {}).get("channelUtilization", 0) chutil2 = "{:.2f}".format(chutil2) + elif "ack" in message.lower(): + if hop == "Direct": + bot_response = "🏓ACK-ACK! " + f"SNR:{snr} RSSI:{rssi}" + else: + bot_response = "🏓ACK-ACK! " + hop elif "testing" in message.lower() or "test" in message.lower(): - bot_response = "🏓Testing 1,2,3" + if hop == "Direct": + bot_response = "🏓Testing 1,2,3 " + f"SNR:{snr} RSSI:{rssi}" + else: + bot_response = "🏓Testing 1,2,3 " + hop else: bot_response = "I'm sorry, I'm afraid I can't do that."