Update mesh_bot.py

This commit is contained in:
SpudGunMan
2024-08-12 02:57:34 -07:00
parent bdd41c0434
commit 65609c5822
+4 -4
View File
@@ -45,14 +45,14 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi
cmds = [] # list to hold the commands found in the message
for key in command_handler:
if key in message_lower:
cmds.append({'key': key, 'index': message_lower.index(key)})
cmds.append({key,message_lower.index(key)})
if len(cmds) > 0:
# sort the commands by index
cmds.sort(key=lambda x: x['index'])
cmds.sort(key=lambda x: x[1])
logger.debug(f"System: Bot Detected: {cmds}")
# run the last command found in the message
bot_response = command_handler[cmds[0]]()
# run the first command after sorting
bot_response = command_handler[cmds[0].pop()]()
# wait a 700ms to avoid message collision from lora-ack
time.sleep(0.7)