From 195e6327e0779a95e4c8133b7626bd72d3e39911 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 4 Oct 2024 00:55:25 -0700 Subject: [PATCH] enhance --- etc/report_generator.py | 16 +++++++++++++--- mesh_bot.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/etc/report_generator.py b/etc/report_generator.py index a5d5caf..719e789 100644 --- a/etc/report_generator.py +++ b/etc/report_generator.py @@ -83,10 +83,12 @@ def parse_log_file(file_path): log_data['command_timestamps'].append((timestamp.isoformat(), 'LLM Query')) command = re.search(r"'cmd': '(\w+)'", line) + user = re.search(r"'user': '(\w+)'", line) if command: cmd = command.group(1) log_data['command_counts'][cmd] += 1 - log_data['command_timestamps'].append((timestamp.isoformat(), cmd)) + # include the user who sent the command + log_data['command_timestamps'].append((timestamp.isoformat(), cmd + f' from {user}')) if 'Sending DM:' in line or 'Sending Multi-Chunk DM:' in line or 'SendingChannel:' in line or 'Sending Multi-Chunk Message:' in line: log_data['message_types']['Outgoing DM'] += 1 @@ -96,7 +98,15 @@ def parse_log_file(file_path): if 'Received DM:' in line or 'Ignoring DM:' in line or 'Ignoring Message:' in line or 'ReceivedChannel:' in line or 'LLM Query:' in line: log_data['message_types']['Incoming DM'] += 1 log_data['total_messages'] += 1 - log_data['message_timestamps'].append((timestamp.isoformat(), 'Incoming DM')) + # include a little of the message + if 'Ignoring Message:' in line: + log_data['message_timestamps'].append((timestamp.isoformat(), f'Incoming: {line.split("Ignoring Message:")[1][:90]}')) + elif 'Ignoring DM:' in line: + log_data['message_timestamps'].append((timestamp.isoformat(), f'Incoming: {line.split("Ignoring DM:")[1][:90]}')) + elif 'LLM Query:' in line: + log_data['message_timestamps'].append((timestamp.isoformat(), f'Incoming: {line.split("LLM Query:")[1][:90]}')) + else: + log_data['message_timestamps'].append((timestamp.isoformat(), 'Incoming:')) # check for shame words in the message for word in shameWordList: if word in line.lower(): @@ -460,7 +470,7 @@ def generate_main_html(log_data, system_info):
-
Message Counts
+
BBS Stored Message Counts
diff --git a/mesh_bot.py b/mesh_bot.py index bd63f6e..ce67b84 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -88,7 +88,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n if len(cmds) > 0: # sort the commands by index value cmds = sorted(cmds, key=lambda k: k['index']) - logger.debug(f"System: Bot detected Commands:{cmds}") + logger.debug(f"System: Bot detected Commands:{cmds} From: {get_name_from_number(message_from_id)}") # check the command isnt a isDM only command if cmds[0]['cmd'] in restrictedCommands and not isDM: bot_response = restrictedResponse