From 544c4c3e805876b96747227e0bfdd55e2c1a165c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Sep 2024 23:18:06 -0700 Subject: [PATCH] Update mesh_bot.py --- mesh_bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 4ba742f..55712b9 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -147,7 +147,7 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel # if the message_from_id is not in the llmLocationTable send the welcome message for i in range(0, len(llmLocationTable)): - if llmLocationTable[i].get('nodeID') == message_from_id: + if not any(d['nodeID'] == message_from_id for d in llmLocationTable): if (channel_number == publicChannel and antiSpam) or useDMForResponse: # send via DM send_message(welcome_message, channel_number, message_from_id, deviceID) @@ -161,8 +161,10 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel for i in range(0, len(llmLocationTable)): if llmLocationTable[i].get('nodeID') == message_from_id: llmLocationTable[i]['location'] = location_name - else: - llmLocationTable.append({'nodeID': message_from_id, 'location': location_name}) + + # if not in table add the location + if not any(d['nodeID'] == message_from_id for d in llmLocationTable): + llmLocationTable.append({'nodeID': message_from_id, 'location': location_name}) user_input = user_input.strip()