From ee49f6923161b3dc7a023b2b7534dcc8824e4cee Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 4 Oct 2024 17:23:00 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hop count limit for games to keep network use ok --- config.template | 2 ++ mesh_bot.py | 5 ++++- modules/settings.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.template b/config.template index 62eb678..1f32c44 100644 --- a/config.template +++ b/config.template @@ -133,3 +133,5 @@ responseDelay = 0.7 splitDelay = 0.0 # message chunk size for sending at high success rate MESSAGE_CHUNK_SIZE = 160 +# if hop limit for the user exceeds this value, the message will be dropped +game_hop_limit = 5 diff --git a/mesh_bot.py b/mesh_bot.py index dfdd821..a08b42f 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -1044,8 +1044,11 @@ def onReceive(packet, interface): 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: + if games_enabled and (hop == "Direct" or hop_count < game_hop_limit): playingGame = checkPlayingGame(message_from_id, message_string, rxNode, channel_number) + else: + playingGame = False + logger.warning(f"Device:{rxNode} Ignoring Request to Play Game: {message_string} From: {get_name_from_number(message_from_id, 'long', rxNode)} with hop count: {hop}") if not playingGame: if llm_enabled: diff --git a/modules/settings.py b/modules/settings.py index 3077c73..930c728 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -164,6 +164,7 @@ try: responseDelay = config['messagingSettings'].getfloat('responseDelay', 0.7) # default 0.7 splitDelay = config['messagingSettings'].getfloat('splitDelay', 0) # default 0 MESSAGE_CHUNK_SIZE = config['messagingSettings'].getint('MESSAGE_CHUNK_SIZE', 160) # default 160 + game_hop_limit = config['messagingSettings'].getint('game_hop_limit', 5) # default 3 hops except KeyError as e: print(f"System: Error reading config file: {e}")