From c42b6cccb152cabda40e8159b0dd9b4028b46f63 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 4 Oct 2024 20:33:48 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=B9=EF=B8=8F=F0=9F=93=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/report_generator.py | 23 ++++++++++++----------- etc/report_generator5.py | 17 +++++++++++++---- mesh_bot.py | 14 +++++++++++--- modules/games/lemonade.py | 2 -- modules/games/mmind.py | 2 -- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/etc/report_generator.py b/etc/report_generator.py index 1d4cd10..e2d96c4 100644 --- a/etc/report_generator.py +++ b/etc/report_generator.py @@ -77,20 +77,21 @@ def parse_log_file(file_path): timestamp = datetime.strptime(timestamp_match.group(1), '%Y-%m-%d %H:%M:%S') log_data['hourly_activity'][timestamp.strftime('%Y-%m-%d %H:00:00')] += 1 - if 'Bot detected Commands' in line or 'LLM Query:' in line: + if 'Bot detected Commands' in line or 'LLM Query:' in line or 'PlayingGame' in line: + # get the command and user from the line + command = re.search(r"'cmd': '(\w+)'", line) + user = re.search(r"From: (\w+)", line) + if 'LLM Query:' in line: log_data['command_counts']['LLM Query'] += 1 log_data['command_timestamps'].append((timestamp.isoformat(), 'LLM Query')) - - command = re.search(r"'cmd': '(\w+)'", line) - user = re.search(r"From: (\w+)", line) - if user: - user = user.group(1) - if command: - cmd = command.group(1) - log_data['command_counts'][cmd] += 1 - # include the user who sent the command - log_data['command_timestamps'].append((timestamp.isoformat(), cmd + f' from {user}')) + + if 'PlayingGame' in line: + #log line looks like this. 2024-10-04 20:24:53,381 | DEBUG | System: 862418040 PlayingGame BlackJack last_cmd: new + game = re.search(r'PlayingGame (\w+)', line) + user = re.search(r'System: (\d+)', line) + log_data['command_counts'][game.group(1)] += 1 + log_data['command_timestamps'].append((timestamp.isoformat(), game)) 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 diff --git a/etc/report_generator5.py b/etc/report_generator5.py index 6f13424..b6c833b 100644 --- a/etc/report_generator5.py +++ b/etc/report_generator5.py @@ -79,13 +79,22 @@ def parse_log_file(file_path): timestamp = datetime.strptime(timestamp_match.group(1), '%Y-%m-%d %H:%M:%S') log_data['hourly_activity'][timestamp.strftime('%Y-%m-%d %H:00:00')] += 1 - if 'Bot detected Commands' in line or 'LLM Query:' in line: + if 'Bot detected Commands' in line or 'LLM Query:' in line or 'PlayingGame' in line: + # get the command and user from the line + command = re.search(r"'cmd': '(\w+)'", line) + user = re.search(r"From: (\w+)", line) + if 'LLM Query:' in line: log_data['command_counts']['LLM Query'] += 1 log_data['command_timestamps'].append((timestamp.isoformat(), 'LLM Query')) - - command = re.search(r"'cmd': '(\w+)'", line) - user = re.search(r"From: (\w+)", line) + + if 'PlayingGame' in line: + #log line looks like this. 2024-10-04 20:24:53,381 | DEBUG | System: 862418040 PlayingGame BlackJack last_cmd: new + game = re.search(r'PlayingGame (\w+)', line) + user = re.search(r'System: (\d+)', line) + log_data['command_counts'][game.group(1)] += 1 + log_data['command_timestamps'].append((timestamp.isoformat(), game)) + if user: user = user.group(1) if command: diff --git a/mesh_bot.py b/mesh_bot.py index a08b42f..38ddf6b 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -337,7 +337,7 @@ def handleDopeWars(nodeID, message, rxNode): msg += 'The High Score is $' + "{:,}".format(high_score.get('cash')) + ' by user ' + get_name_from_number(high_score.get('userID') , 'short', rxNode) +'\n' msg += playDopeWars(nodeID, message) else: - logger.debug("System: DopeWars: last_cmd: " + str(last_cmd)) + logger.debug(f"System: {nodeID} PlayingGame dopewars last_cmd: {last_cmd}") msg = playDopeWars(nodeID, message) # wait a second to keep from message collision time.sleep(1) @@ -376,6 +376,8 @@ def handleLemonade(nodeID, message): for i in range(len(lemonadeTracker)): if lemonadeTracker[i]['nodeID'] == nodeID: last_cmd = lemonadeTracker[i]['cmd'] + + logger.debug(f"System: {nodeID} PlayingGame lemonstand last_cmd: {last_cmd}") # create new player if not in tracker if last_cmd == "" and nodeID != 0: create_player(nodeID) @@ -420,7 +422,7 @@ def handleBlackJack(nodeID, message): msg = playBlackJack(nodeID=nodeID, message=message) if last_cmd != "" and nodeID != 0: - logger.debug(f"System: BlackJack: {nodeID} last command: {last_cmd}") + logger.debug(f"System: {nodeID} PlayingGame blackjack last_cmd: {last_cmd}") else: highScore = {'nodeID': 0, 'highScore': 0} highScore = loadHSJack() @@ -467,7 +469,7 @@ def handleVideoPoker(nodeID, message): msg += f" HighScore🥇{nodeName} with {highScore['highScore']} coins. " if last_cmd != "" and nodeID != 0: - logger.debug(f"System: VideoPoker: {nodeID} last command: {last_cmd}") + logger.debug(f"System: {nodeID} PlayingGame videopoker last_cmd: {last_cmd}") time.sleep(1.5) # short answers with long replies can cause message collision added wait return msg @@ -493,6 +495,8 @@ def handleMmind(nodeID, deviceID, message): if mindTracker[i]['nodeID'] == nodeID: last_cmd = mindTracker[i]['cmd'] + logger.debug(f"System: {nodeID} PlayingGame mastermind last_cmd: {last_cmd}") + if last_cmd == "" and nodeID != 0: # create new player logger.debug("System: MasterMind: New Player: " + str(nodeID)) @@ -525,6 +529,8 @@ def handleGolf(nodeID, message): golfTracker.pop(i) return msg + logger.debug(f"System: {nodeID} PlayingGame golfsim last_cmd: {last_cmd}") + if last_cmd == "" and nodeID != 0: # create new player logger.debug("System: GolfSim: New Player: " + str(nodeID)) @@ -547,6 +553,8 @@ def handleUno(nodeID, deviceID, message): if unoTracker[i]['nodeID'] == nodeID: last_cmd = unoTracker[i]['cmd'] + logger.debug(f"System: {nodeID} PlayingGame uno last_cmd: {last_cmd}") + if last_cmd == "" and nodeID != 0: # create new player logger.debug("System: Uno: New Player: " + str(nodeID) + " " + get_name_from_number(nodeID)) diff --git a/modules/games/lemonade.py b/modules/games/lemonade.py index 0969de6..8678a26 100644 --- a/modules/games/lemonade.py +++ b/modules/games/lemonade.py @@ -236,8 +236,6 @@ def start_lemonade(nodeID, message, celsius=False): score.value = lemonadeScore[i]['value'] score.total = lemonadeScore[i]['total'] - logger.debug("System: Lemonade: Last Command: " + last_cmd) - # Start the main loop if (weeks.current <= weeks.total): diff --git a/modules/games/mmind.py b/modules/games/mmind.py index 36bac57..8b5516d 100644 --- a/modules/games/mmind.py +++ b/modules/games/mmind.py @@ -296,8 +296,6 @@ def start_mMind(nodeID, message): if mindTracker[i]['nodeID'] == nodeID: last_cmd = mindTracker[i]['cmd'] - logger.debug("System: MasterMind: last_cmd: " + str(last_cmd)) - if last_cmd == "new": if message.lower().startswith("n") or message.lower().startswith("h") or message.lower().startswith("x"): diff = message.lower()[0]