diff --git a/README.md b/README.md index 3cd510e..f4d43e4 100644 --- a/README.md +++ b/README.md @@ -358,6 +358,7 @@ There is no direct support for MQTT in the code, however, reports from Discord a | `motd` | Displays the message of the day or sets it. Example: `motd $New Message Of the day` | ✅ | | `lheard` | Returns the last 5 heard nodes with SNR. Can also use `sitrep` | ✅ | | `history` | Returns the last commands run by user(s) | ✅ | +| `sysinfo` | Returns the telemetry info | ✅ | | `cmd` | Returns the list of commands (the help message) | ✅ | ### Radio Propagation & Weather Forcasting diff --git a/mesh_bot.py b/mesh_bot.py index 9b67f82..ed90931 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -14,8 +14,6 @@ restrictedCommands = ["blackjack", "videopoker", "dopewars", "lemonstand", "golf restrictedResponse = "🤖only available in a Direct Message📵" # "" for none # Global Variables -cmdHistory = [] # list to hold the last commands -seenNodes = [] # list to hold the last seen nodes DEBUGpacket = False # Debug print the packet rx DEBUGhops = False # Debug print hop info and bad hop count packets @@ -72,6 +70,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "sms:": lambda: handle_sms(message_from_id, message), "solar": lambda: drap_xray_conditions() + "\n" + solar_conditions(), "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), + "sysinfo": lambda: sysinfo(message, message_from_id, deviceID), "test": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "testing": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "tide": lambda: handle_tide(message_from_id, deviceID, channel_number), @@ -736,6 +735,12 @@ def handle_sun(message_from_id, deviceID, channel_number): location = get_node_location(message_from_id, deviceID, channel_number) return get_sun(str(location[0]), str(location[1])) +def sysinfo(message, message_from_id, deviceID): + if "?" in message: + return "sysinfo command returns system information." + else: + return get_sysinfo(message_from_id, deviceID) + def handle_lheard(message, nodeid, deviceID, isDM): if "?" in message and isDM: return message.split("?")[0].title() + " command returns a list of the nodes that have been heard recently" diff --git a/modules/settings.py b/modules/settings.py index 78de685..b234346 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -28,6 +28,8 @@ retry_int2 = False wiki_return_limit = 3 # limit the number of sentences returned off the first paragraph first hit playingGame = False GAMEDELAY = 28800 # 8 hours in seconds for game mode holdoff +cmdHistory = [] # list to hold the last commands +seenNodes = [] # list to hold the last seen nodes # Read the config file, if it does not exist, create basic config file config = configparser.ConfigParser() diff --git a/modules/system.py b/modules/system.py index 5ea36b9..fec25b9 100644 --- a/modules/system.py +++ b/modules/system.py @@ -18,7 +18,6 @@ asyncLoop = asyncio.new_event_loop() games_enabled = False multiPingList = [{'message_from_id': 0, 'count': 0, 'type': '', 'deviceID': 0, 'channel_number': 0, 'startCount': 0}] - # Ping Configuration if ping_enabled: # ping, pinging, ack, testing, test, pong @@ -28,9 +27,9 @@ if ping_enabled: # Sitrep Configuration if sitrep_enabled: - trap_list_sitrep = ("sitrep", "lheard") + trap_list_sitrep = ("sitrep", "lheard", "sysinfo") trap_list = trap_list + trap_list_sitrep - help_message = help_message + ", sitrep" + help_message = help_message + ", sitrep, sysinfo" # MOTD Configuration if motd_enabled: @@ -901,7 +900,18 @@ def consumeMetadata(packet, rxNode=0): if debugMetadata: print(f"DEBUG REMOTE_HARDWARE_APP: {packet}\n\n") # get the remote hardware data remote_hardware_data = packet['decoded']['remoteHardware'] - + +def get_sysinfo(nodeID=0, deviceID=1): + # Get the system telemetry data for return on the sysinfo command + sysinfo = '' + stats = displayNodeTelemetry(nodeID, deviceID) + " 🤖👀" + str(len(seenNodes)) + # replace Telemetry with Int in string + stats = stats.replace("Telemetry", "Int") + sysinfo += f"📊{stats}" + if interface2_enabled: + sysinfo += f"📊{stats}" + + return sysinfo async def BroadcastScheduler(): # handle schedule checks for the broadcast of messages diff --git a/pong_bot.py b/pong_bot.py index c3007e6..97fb6e4 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -9,7 +9,6 @@ from modules.log import * from modules.system import * # Global Variables -cmdHistory = [] # list to hold the last commands DEBUGpacket = False # Debug print the packet rx def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_number, deviceID, isDM): @@ -29,6 +28,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "ping": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "pong": lambda: "🏓PING!!🛜", "sitrep": lambda: handle_lheard(interface1, interface2_enabled, myNodeNum1, myNodeNum2), + "sysinfo": lambda: sysinfo(message, message_from_id, deviceID), "test": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "testing": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), } @@ -140,6 +140,12 @@ def handle_motd(message): return "MOTD Set to: " + MOTD else: return MOTD + +def sysinfo(message, message_from_id, deviceID): + if "?" in message: + return "sysinfo command returns system information." + else: + return get_sysinfo(message_from_id, deviceID) def handle_lheard(message, nodeid, deviceID, isDM): if "?" in message and isDM: