diff --git a/README.md b/README.md index 22e27ff..811cab4 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,7 @@ There is no direct support for MQTT in the code, however, reports from Discord a | `test` | Returns like ping but also can be used to test the limits of data buffers `test 4` sends data to the maxBuffer limit (default 220) | ✅ | | `whereami` | Returns the address of the sender's location if known | | `whoami` | Returns details of the node asking, also returned when position exchanged 📍 | ✅ | +| `whois` | Returns details known about node, more data with bbsadmin node | ✅ | | `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) | ✅ | diff --git a/mesh_bot.py b/mesh_bot.py index 6b8b8fd..0f9454f 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -77,6 +77,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "videopoker": lambda: handleVideoPoker(message, message_from_id, deviceID), "whereami": lambda: handle_whereami(message_from_id, deviceID, channel_number), "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus), + "whois": lambda: handle_whois(message, deviceID, channel_number, message_from_id), "wiki:": lambda: handle_wiki(message, isDM), "wiki?": lambda: handle_wiki(message, isDM), "wx": lambda: handle_wxc(message_from_id, deviceID, 'wx'), @@ -813,6 +814,46 @@ def handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus): msg = "Error in whoami" return msg +def handle_whois(message, deviceID, channel_number, message_from_id): + #return data on a node name or number + if "?" in message: + return message.split("?")[0].title() + " command returns information on a node." + else: + # get the nodeID from the message + msg = '' + node = '' + # find the requested node in db + if " " in message: + node = message.split(" ")[1] + if node.startswith("!") and len(node) == 9: + # mesh !hex + try: + node = int(node.strip("!"),16) + except ValueError as e: + node = 0 + elif node.isalpha() or not node.isnumeric(): + # try short name + node = get_num_from_short_name(node, deviceID) + + # get details on the node + for i in range(len(seenNodes)): + if seenNodes[i]['nodeID'] == int(node): + msg = f"Node: {seenNodes[i]['nodeID']} is {get_name_from_number(seenNodes[i]['nodeID'], 'long', deviceID)}\n" + msg += f"Last 👀: {time.ctime(seenNodes[i]['lastSeen'])} " + break + + if msg == '': + msg = "Provide a valid node number or short name" + else: + # if the user is an admin show the channel and interface and location + if str(message_from_id) in bbs_admin_list: + location = get_node_location(seenNodes[i]['nodeID'], deviceID, channel_number) + msg += f"Ch: {seenNodes[i]['channel']}, Int: {seenNodes[i]['rxInterface']}" + msg += f"Lat: {location[0]}, Lon: {location[1]}\n" + msg += f"Loc: {where_am_i(str(location[0]), str(location[1]))}\n" + + return msg + def check_and_play_game(tracker, message_from_id, message_string, rxNode, channel_number, game_name, handle_game_func): global llm_enabled diff --git a/modules/system.py b/modules/system.py index 11330a8..b63de87 100644 --- a/modules/system.py +++ b/modules/system.py @@ -51,9 +51,9 @@ if emergency_responder_enabled: # whoami Configuration if whoami_enabled: - trap_list_whoami = ("whoami", "📍") + trap_list_whoami = ("whoami", "📍", "whois") trap_list = trap_list + trap_list_whoami - help_message = help_message + ", whoami" + help_message = help_message + ", whoami, whois" # Solar Conditions Configuration if solar_conditions_enabled: @@ -513,7 +513,7 @@ def send_message(message, ch, nodeid=0, nodeInt=1, bypassChuncking=False): if nodeid == 0: # Send to channel if wantAck: - logger.info(f"Device:{nodeInt} Channel:{ch} " + CustomFormatter.red + f"req.ACK " + "Chunker{chunkOf} SendingChannel: " + CustomFormatter.white + m.replace('\n', ' ')) + logger.info(f"Device:{nodeInt} Channel:{ch} " + CustomFormatter.red + f"req.ACK " + f"Chunker{chunkOf} SendingChannel: " + CustomFormatter.white + m.replace('\n', ' ')) interface.sendText(text=m, channelIndex=ch, wantAck=True) else: logger.info(f"Device:{nodeInt} Channel:{ch} " + CustomFormatter.red + f"Chunker{chunkOf} SendingChannel: " + CustomFormatter.white + m.replace('\n', ' '))