From a13d98e32bc43dbf46f047751463fd2a9252ab48 Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 01:19:18 +0100 Subject: [PATCH 1/9] 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 4d941b9..d437c67 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -667,6 +667,7 @@ def onReceive(packet, interface): hop = 0 hop_away = 0 pkiStatus = (False, 'ABC') + isDM = False if DEBUGpacket: # Debug print the interface object @@ -760,7 +761,7 @@ def onReceive(packet, interface): hop = f"{hop_count} hops" - if message_string == help_message or message_string == welcome_message or "CMD?:" in message_string: + if message_string == help_message or message_string == welcome_message or message_string == "CMD?:" in message_string: # ignore help and welcome messages logger.warning(f"Got Own Welcome/Help header. From: {get_name_from_number(message_from_id, 'long', rxNode)}") return @@ -768,14 +769,15 @@ def onReceive(packet, interface): # If the packet is a DM (Direct Message) respond to it, otherwise validate its a message for us on the channel if packet['to'] == myNodeNum1 or packet['to'] == myNodeNum2: # message is DM to us + isDM = True # check if the message contains a trap word, DMs are always responded to if messageTrap(message_string): logger.info(f"Device:{rxNode} Channel: {channel_number} " + CustomFormatter.green + f"Received DM: " + CustomFormatter.white + f"{message_string} " + CustomFormatter.purple +\ "From: " + CustomFormatter.white + f"{get_name_from_number(message_from_id, 'long', rxNode)}") # respond with DM - send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode), channel_number, message_from_id, rxNode) + send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode), channel_number, message_from_id, rxNode, isDM) else: - # DM is usefull for games or LLM + # DM is useful for games or LLM if games_enabled: playingGame = False # if in a game we cant use LLM disable for duration of game From b8f8f804996c352dfac57340e57dc0bd934cb482 Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 01:28:47 +0100 Subject: [PATCH 2/9] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index d437c67..2bc0637 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -761,7 +761,7 @@ def onReceive(packet, interface): hop = f"{hop_count} hops" - if message_string == help_message or message_string == welcome_message or message_string == "CMD?:" in message_string: + if message_string == help_message or message_string == welcome_message or "CMD?:" in message_string.lower(): # ignore help and welcome messages logger.warning(f"Got Own Welcome/Help header. From: {get_name_from_number(message_from_id, 'long', rxNode)}") return From 5052e2510e29644c0078d3afdb730b88c34473dd Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 01:33:21 +0100 Subject: [PATCH 3/9] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 2bc0637..f6884bb 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -761,7 +761,7 @@ def onReceive(packet, interface): hop = f"{hop_count} hops" - if message_string == help_message or message_string == welcome_message or "CMD?:" in message_string.lower(): + if message_string == help_message or message_string == welcome_message or "cmd?:" in message_string.lower(): # ignore help and welcome messages logger.warning(f"Got Own Welcome/Help header. From: {get_name_from_number(message_from_id, 'long', rxNode)}") return From 3ec89decf0b334875c2a9b3930eb387cd380ba1e Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:36:39 +0100 Subject: [PATCH 4/9] Update mesh_bot.py --- mesh_bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index f6884bb..3879a6b 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -13,7 +13,7 @@ DEBUGpacket = False # Debug print the packet rx # Global Variables cmdHistory = [] # list to hold the last commands -def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_number, deviceID): +def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_number, deviceID, isDM): global cmdHistory #Auto response to messages message_lower = message.lower() @@ -775,7 +775,7 @@ def onReceive(packet, interface): logger.info(f"Device:{rxNode} Channel: {channel_number} " + CustomFormatter.green + f"Received DM: " + CustomFormatter.white + f"{message_string} " + CustomFormatter.purple +\ "From: " + CustomFormatter.white + f"{get_name_from_number(message_from_id, 'long', rxNode)}") # respond with DM - send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode), channel_number, message_from_id, rxNode, isDM) + send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode, isDM), channel_number, message_from_id, rxNode) else: # DM is useful for games or LLM if games_enabled: From c7ef22f5c237d7575aa8510e17ca1721557fe517 Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:41:52 +0100 Subject: [PATCH 5/9] Update mesh_bot.py --- mesh_bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 3879a6b..fe0db7c 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -873,7 +873,7 @@ def onReceive(packet, interface): "From: " + CustomFormatter.white + f"{get_name_from_number(message_from_id, 'long', rxNode)}") if useDMForResponse: # respond to channel message via direct message - send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode), channel_number, message_from_id, rxNode) + send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode, isDM), channel_number, message_from_id, rxNode) else: # or respond to channel message on the channel itself if channel_number == publicChannel and antiSpam: @@ -881,10 +881,10 @@ def onReceive(packet, interface): logger.error(f"System: AntiSpam protection, sending DM to: {get_name_from_number(message_from_id, 'long', rxNode)}") # respond to channel message via direct message - send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode), channel_number, message_from_id, rxNode) + send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode, isDM), channel_number, message_from_id, rxNode) else: # respond to channel message on the channel itself - send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode), channel_number, 0, rxNode) + send_message(auto_response(message_string, snr, rssi, hop, pkiStatus, message_from_id, channel_number, rxNode, isDM), channel_number, 0, rxNode) else: # message is not for bot to respond to # ignore the message but add it to the message history list From 5d2d6bc5fb792fde4d53d199dcf5ad79a8ede3bc Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:53:42 +0100 Subject: [PATCH 6/9] utilise isDM to split responses --- mesh_bot.py | 92 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index fe0db7c..c931279 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -18,47 +18,59 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n #Auto response to messages message_lower = message.lower() bot_response = "I'm sorry, I'm afraid I can't do that." + if isDM: + command_handler = { + "ping": lambda: handle_ping(message, hop, snr, rssi), + "pong": lambda: "🏓PING!!", + "motd": lambda: handle_motd(message, message_from_id), + "bbshelp": bbs_help, + "wxalert": lambda: handle_wxalert(message_from_id, deviceID, message), + "wxa": lambda: handle_wxalert(message_from_id, deviceID, message), + "wxc": lambda: handle_wxc(message_from_id, deviceID, 'wxc'), + "wx": lambda: handle_wxc(message_from_id, deviceID, 'wx'), + "wiki:": lambda: handle_wiki(message), + "games": lambda: gamesCmdList, + "dopewars": lambda: handleDopeWars(message_from_id, message, deviceID), + "lemonstand": lambda: handleLemonade(message_from_id, message), + "blackjack": lambda: handleBlackJack(message_from_id, message), + "videopoker": lambda: handleVideoPoker(message_from_id, message), + "globalthermonuclearwar": lambda: handle_gTnW(), + "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), + "askai": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), + "joke": tell_joke, + "bbslist": bbs_list_messages, + "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), + "bbsread": lambda: handle_bbsread(message), + "bbsdelete": lambda: handle_bbsdelete(message, message_from_id), + "messages": lambda: handle_messages(deviceID, channel_number, msg_history, publicChannel), + "cmd": lambda: help_message, + "cmd?": lambda: help_message, + "history": lambda: handle_history(message_from_id, deviceID), + "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), + "hfcond": hf_band_conditions, + "solar": lambda: drap_xray_conditions() + "\n" + solar_conditions(), + "lheard": lambda: handle_lheard(message_from_id, deviceID), + "sitrep": lambda: handle_lheard(message_from_id, deviceID), + "whereami": lambda: handle_whereami(message_from_id, deviceID, channel_number), + "tide": lambda: handle_tide(message_from_id, deviceID, channel_number), + "moon": lambda: handle_moon(message_from_id, deviceID, channel_number), + "ack": lambda: handle_ack(hop, snr, rssi), + "testing": lambda: handle_testing(message, hop, snr, rssi), + "test": lambda: handle_testing(message, hop, snr, rssi), + "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) + } + else: + command_handler = { + "ping": lambda: handle_ping(message, hop, snr, rssi), + "pong": lambda: "🏓PING!!", + "motd": lambda: handle_motd(message, message_from_id), + "ack": lambda: handle_ack(hop, snr, rssi), + "testing": lambda: handle_testing(message, hop, snr, rssi), + "test": lambda: handle_testing(message, hop, snr, rssi), + "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) + } - command_handler = { - "ping": lambda: handle_ping(message, hop, snr, rssi), - "pong": lambda: "🏓PING!!", - "motd": lambda: handle_motd(message, message_from_id), - "bbshelp": bbs_help, - "wxalert": lambda: handle_wxalert(message_from_id, deviceID, message), - "wxa": lambda: handle_wxalert(message_from_id, deviceID, message), - "wxc": lambda: handle_wxc(message_from_id, deviceID, 'wxc'), - "wx": lambda: handle_wxc(message_from_id, deviceID, 'wx'), - "wiki:": lambda: handle_wiki(message), - "games": lambda: gamesCmdList, - "dopewars": lambda: handleDopeWars(message_from_id, message, deviceID), - "lemonstand": lambda: handleLemonade(message_from_id, message), - "blackjack": lambda: handleBlackJack(message_from_id, message), - "videopoker": lambda: handleVideoPoker(message_from_id, message), - "globalthermonuclearwar": lambda: handle_gTnW(), - "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), - "askai": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), - "joke": tell_joke, - "bbslist": bbs_list_messages, - "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), - "bbsread": lambda: handle_bbsread(message), - "bbsdelete": lambda: handle_bbsdelete(message, message_from_id), - "messages": lambda: handle_messages(deviceID, channel_number, msg_history, publicChannel), - "cmd": lambda: help_message, - "cmd?": lambda: help_message, - "history": lambda: handle_history(message_from_id, deviceID), - "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), - "hfcond": hf_band_conditions, - "solar": lambda: drap_xray_conditions() + "\n" + solar_conditions(), - "lheard": lambda: handle_lheard(message_from_id, deviceID), - "sitrep": lambda: handle_lheard(message_from_id, deviceID), - "whereami": lambda: handle_whereami(message_from_id, deviceID, channel_number), - "tide": lambda: handle_tide(message_from_id, deviceID, channel_number), - "moon": lambda: handle_moon(message_from_id, deviceID, channel_number), - "ack": lambda: handle_ack(hop, snr, rssi), - "testing": lambda: handle_testing(message, hop, snr, rssi), - "test": lambda: handle_testing(message, hop, snr, rssi), - "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) - } + cmds = [] # list to hold the commands found in the message for key in command_handler: if key in message_lower.split(' '): From 241e2258e8d5cbd4df0daf78083cd2a0df8c61f5 Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:04:08 +0100 Subject: [PATCH 7/9] Update mesh_bot.py --- mesh_bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index c931279..e3b80a1 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -17,8 +17,8 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n global cmdHistory #Auto response to messages message_lower = message.lower() - bot_response = "I'm sorry, I'm afraid I can't do that." if isDM: + bot_response = "I'm sorry, I'm afraid I can't do that." command_handler = { "ping": lambda: handle_ping(message, hop, snr, rssi), "pong": lambda: "🏓PING!!", @@ -60,6 +60,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) } else: + bot_response = "" command_handler = { "ping": lambda: handle_ping(message, hop, snr, rssi), "pong": lambda: "🏓PING!!", From 169ea8c233eea2c0ed7fcb72756f8a81c16d7f64 Mon Sep 17 00:00:00 2001 From: Nestpebble <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:12:08 +0100 Subject: [PATCH 8/9] Update mesh_bot.py --- mesh_bot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mesh_bot.py b/mesh_bot.py index e3b80a1..75b3850 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -88,6 +88,8 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n if len(cmdHistory) > 50: cmdHistory.pop(0) cmdHistory.append({'nodeID': message_from_id, 'cmd': cmds[0]['cmd'], 'time': time.time()}) + else: + logger.debug(f"System: Bot detected messageTrap but was not a DM") # wait a responseDelay to avoid message collision from lora-ack time.sleep(responseDelay) From e708ec9adc43c740f51d040c3dee8e72533ae278 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 25 Sep 2024 14:27:39 -0700 Subject: [PATCH 9/9] Update mesh_bot.py --- mesh_bot.py | 124 +++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 64 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 69d6a8e..f38d658 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -8,70 +8,64 @@ from pubsub import pub # pip install pubsub from modules.log import * from modules.system import * -DEBUGpacket = False # Debug print the packet rx +# list of commands to remove from the default list for DM only +restrictedCommands = ["blackjack", "videopoker", "dopewars", "lemonstand"] +restrictedResponse = "🤖only available in a Direct Message📵" # "" for none # Global Variables cmdHistory = [] # list to hold the last commands +DEBUGpacket = False # Debug print the packet rx def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_number, deviceID, isDM): global cmdHistory #Auto response to messages message_lower = message.lower() - if isDM: - bot_response = "I'm sorry, I'm afraid I can't do that." - command_handler = { - "ping": lambda: handle_ping(message, hop, snr, rssi), - "pong": lambda: "🏓PING!!", - "motd": lambda: handle_motd(message, message_from_id), - "bbshelp": bbs_help, - "wxalert": lambda: handle_wxalert(message_from_id, deviceID, message), - "wxa": lambda: handle_wxalert(message_from_id, deviceID, message), - "wxc": lambda: handle_wxc(message_from_id, deviceID, 'wxc'), - "wx": lambda: handle_wxc(message_from_id, deviceID, 'wx'), - "wiki:": lambda: handle_wiki(message), - "games": lambda: gamesCmdList, - "dopewars": lambda: handleDopeWars(message_from_id, message, deviceID), - "lemonstand": lambda: handleLemonade(message_from_id, message), - "blackjack": lambda: handleBlackJack(message_from_id, message), - "videopoker": lambda: handleVideoPoker(message_from_id, message), - "globalthermonuclearwar": lambda: handle_gTnW(), - "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), - "askai": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), - "joke": tell_joke, - "bbslist": bbs_list_messages, - "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), - "bbsread": lambda: handle_bbsread(message), - "bbsdelete": lambda: handle_bbsdelete(message, message_from_id), - "messages": lambda: handle_messages(deviceID, channel_number, msg_history, publicChannel), - "cmd": lambda: help_message, - "cmd?": lambda: help_message, - "history": lambda: handle_history(message_from_id, deviceID), - "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), - "hfcond": hf_band_conditions, - "solar": lambda: drap_xray_conditions() + "\n" + solar_conditions(), - "lheard": lambda: handle_lheard(message_from_id, deviceID), - "sitrep": lambda: handle_lheard(message_from_id, deviceID), - "whereami": lambda: handle_whereami(message_from_id, deviceID, channel_number), - "tide": lambda: handle_tide(message_from_id, deviceID, channel_number), - "moon": lambda: handle_moon(message_from_id, deviceID, channel_number), - "ack": lambda: handle_ack(hop, snr, rssi), - "testing": lambda: handle_testing(message, hop, snr, rssi), - "test": lambda: handle_testing(message, hop, snr, rssi), - "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) - } - else: - bot_response = "" - command_handler = { - "ping": lambda: handle_ping(message, hop, snr, rssi), - "pong": lambda: "🏓PING!!", - "motd": lambda: handle_motd(message, message_from_id), - "ack": lambda: handle_ack(hop, snr, rssi), - "testing": lambda: handle_testing(message, hop, snr, rssi), - "test": lambda: handle_testing(message, hop, snr, rssi), - "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) - } + bot_response = "🤖I'm sorry, I'm afraid I can't do that." - + # Command List + default_commands = { + "ping": lambda: handle_ping(message, hop, snr, rssi), + "pong": lambda: "🏓PING!!", + "motd": lambda: handle_motd(message, message_from_id), + "bbshelp": bbs_help, + "wxalert": lambda: handle_wxalert(message_from_id, deviceID, message), + "wxa": lambda: handle_wxalert(message_from_id, deviceID, message), + "wxc": lambda: handle_wxc(message_from_id, deviceID, 'wxc'), + "wx": lambda: handle_wxc(message_from_id, deviceID, 'wx'), + "wiki:": lambda: handle_wiki(message), + "games": lambda: gamesCmdList, + "dopewars": lambda: handleDopeWars(message_from_id, message, deviceID), + "lemonstand": lambda: handleLemonade(message_from_id, message), + "blackjack": lambda: handleBlackJack(message_from_id, message), + "videopoker": lambda: handleVideoPoker(message_from_id, message), + "globalthermonuclearwar": lambda: handle_gTnW(), + "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), + "askai": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), + "joke": tell_joke, + "bbslist": bbs_list_messages, + "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), + "bbsread": lambda: handle_bbsread(message), + "bbsdelete": lambda: handle_bbsdelete(message, message_from_id), + "messages": lambda: handle_messages(deviceID, channel_number, msg_history, publicChannel), + "cmd": lambda: help_message, + "cmd?": lambda: help_message, + "history": lambda: handle_history(message_from_id, deviceID), + "sun": lambda: handle_sun(message_from_id, deviceID, channel_number), + "hfcond": hf_band_conditions, + "solar": lambda: drap_xray_conditions() + "\n" + solar_conditions(), + "lheard": lambda: handle_lheard(message_from_id, deviceID), + "sitrep": lambda: handle_lheard(message_from_id, deviceID), + "whereami": lambda: handle_whereami(message_from_id, deviceID, channel_number), + "tide": lambda: handle_tide(message_from_id, deviceID, channel_number), + "moon": lambda: handle_moon(message_from_id, deviceID, channel_number), + "ack": lambda: handle_ack(hop, snr, rssi), + "testing": lambda: handle_testing(message, hop, snr, rssi), + "test": lambda: handle_testing(message, hop, snr, rssi), + "whoami": lambda: handle_whoami(message_from_id, deviceID, hop, snr, rssi, pkiStatus) + } + + # set the command handler + command_handler = default_commands cmds = [] # list to hold the commands found in the message for key in command_handler: if key in message_lower.split(' '): @@ -82,14 +76,16 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n # sort the commands by index value cmds = sorted(cmds, key=lambda k: k['index']) logger.debug(f"System: Bot detected Commands:{cmds}") - # run the first command after sorting - bot_response = command_handler[cmds[0]['cmd']]() - # append the command to the cmdHistory list for lheard and history - if len(cmdHistory) > 50: - cmdHistory.pop(0) - cmdHistory.append({'nodeID': message_from_id, 'cmd': cmds[0]['cmd'], 'time': time.time()}) - else: - logger.debug(f"System: Bot detected messageTrap but was not a DM") + # check the command isnt a isDM only command + if cmds[0]['cmd'] in restrictedCommands and not isDM: + bot_response = restrictedResponse + else: + # run the first command after sorting + bot_response = command_handler[cmds[0]['cmd']]() + # append the command to the cmdHistory list for lheard and history + if len(cmdHistory) > 50: + cmdHistory.pop(0) + cmdHistory.append({'nodeID': message_from_id, 'cmd': cmds[0]['cmd'], 'time': time.time()}) # wait a responseDelay to avoid message collision from lora-ack time.sleep(responseDelay) @@ -776,7 +772,7 @@ def onReceive(packet, interface): hop = f"{hop_count} hops" - if message_string == help_message or message_string == welcome_message or "cmd?:" in message_string.lower(): + if message_string == help_message or message_string == welcome_message or "CMD?:" in message_string: # ignore help and welcome messages logger.warning(f"Got Own Welcome/Help header. From: {get_name_from_number(message_from_id, 'long', rxNode)}") return