diff --git a/config.template b/config.template index 4d3abd9..46994d8 100644 --- a/config.template +++ b/config.template @@ -25,7 +25,7 @@ port = /dev/ttyUSB0 [general] # if False will respond on all channels but the default channel respond_by_dm_only = True -# Allows auto-ping feature in a channel, False forces DM +# Allows auto-ping feature in a channel, False forces to 1 ping only autoPingInChannel = False # defaultChannel is the meshtastic default public channel, e.g. LongFast (if none use -1) defaultChannel = 0 diff --git a/mesh_bot.py b/mesh_bot.py index ed90931..2762ccd 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -181,31 +181,32 @@ def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, chann multiPingList.pop(i) msg = "🛑 auto-ping" - # disabled in channel - if autoPingInChannel and not isDM: - # if 3 or more entries (2 or more active), throttle the multi-ping for congestion - if len(multiPingList) > 2: - msg = "🚫⛔️ auto-ping, service busy. ⏳Try again soon." - pingCount = -1 - else: - # set inital pingCount - try: - pingCount = int(message.split(" ")[1]) - if pingCount == 123 or pingCount == 1234: - pingCount = 1 - if pingCount > 51: - pingCount = 50 - except: - pingCount = -1 - - if pingCount > 1: - multiPingList.append({'message_from_id': message_from_id, 'count': pingCount + 1, 'type': type, 'deviceID': deviceID, 'channel_number': channel_number, 'startCount': pingCount}) - if type == "🎙TEST": - msg = f"🛜Initalizing BufferTest, using chunks of about {int(maxBuffer // pingCount)}, max length {maxBuffer} in {pingCount} messages" - else: - msg = f"🚦Initalizing {pingCount} auto-ping" + + # if 3 or more entries (2 or more active), throttle the multi-ping for congestion + if len(multiPingList) > 2: + msg = "🚫⛔️ auto-ping, service busy. ⏳Try again soon." + pingCount = -1 else: - msg = "🔊AutoPing via DM only⛔️" + # set inital pingCount + try: + pingCount = int(message.split(" ")[1]) + if pingCount == 123 or pingCount == 1234: + pingCount = 1 + elif not autoPingInChannel and not isDM: + # no autoping in channels + pingCount = 1 + + if pingCount > 51: + pingCount = 50 + except: + pingCount = -1 + + if pingCount > 1: + multiPingList.append({'message_from_id': message_from_id, 'count': pingCount + 1, 'type': type, 'deviceID': deviceID, 'channel_number': channel_number, 'startCount': pingCount}) + if type == "🎙TEST": + msg = f"🛜Initalizing BufferTest, using chunks of about {int(maxBuffer // pingCount)}, max length {maxBuffer} in {pingCount} messages" + else: + msg = f"🚦Initalizing {pingCount} auto-ping" # if not a DM add the username to the beginning of msg if not useDMForResponse and not isDM: diff --git a/modules/system.py b/modules/system.py index 3320258..fc6da53 100644 --- a/modules/system.py +++ b/modules/system.py @@ -765,7 +765,7 @@ def displayNodeTelemetry(nodeID=0, rxNode=0, userRequested=False): telemetryData[0]['interface2'] = time.time() # some telemetry data is not available in python-meshtastic? - # bring in values from the last telemetry request for the node + # bring in values from the last telemetry dump for the node numPacketsTx = telemetryData[rxNode]['numPacketsTx'] numPacketsRx = telemetryData[rxNode]['numPacketsRx'] numPacketsTxErr = telemetryData[rxNode]['numPacketsTxErr'] diff --git a/pong_bot.py b/pong_bot.py index 97fb6e4..cb1dd8f 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -100,31 +100,32 @@ def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, chann multiPingList.pop(i) msg = "🛑 auto-ping" - # disabled in channel - if autoPingInChannel and not isDM: - # if 3 or more entries (2 or more active), throttle the multi-ping for congestion - if len(multiPingList) > 2: - msg = "🚫⛔️ auto-ping, service busy. ⏳Try again soon." - pingCount = -1 - else: - # set inital pingCount - try: - pingCount = int(message.split(" ")[1]) - if pingCount == 123 or pingCount == 1234: - pingCount = 1 - if pingCount > 51: - pingCount = 50 - except: - pingCount = -1 - - if pingCount > 1: - multiPingList.append({'message_from_id': message_from_id, 'count': pingCount + 1, 'type': type, 'deviceID': deviceID, 'channel_number': channel_number, 'startCount': pingCount}) - if type == "🎙TEST": - msg = f"🛜Initalizing BufferTest, using chunks of about {int(maxBuffer // pingCount)}, max length {maxBuffer} in {pingCount} messages" - else: - msg = f"🚦Initalizing {pingCount} auto-ping" + + # if 3 or more entries (2 or more active), throttle the multi-ping for congestion + if len(multiPingList) > 2: + msg = "🚫⛔️ auto-ping, service busy. ⏳Try again soon." + pingCount = -1 else: - msg = "🔊AutoPing via DM only⛔️" + # set inital pingCount + try: + pingCount = int(message.split(" ")[1]) + if pingCount == 123 or pingCount == 1234: + pingCount = 1 + elif not autoPingInChannel and not isDM: + # no autoping in channels + pingCount = 1 + + if pingCount > 51: + pingCount = 50 + except: + pingCount = -1 + + if pingCount > 1: + multiPingList.append({'message_from_id': message_from_id, 'count': pingCount + 1, 'type': type, 'deviceID': deviceID, 'channel_number': channel_number, 'startCount': pingCount}) + if type == "🎙TEST": + msg = f"🛜Initalizing BufferTest, using chunks of about {int(maxBuffer // pingCount)}, max length {maxBuffer} in {pingCount} messages" + else: + msg = f"🚦Initalizing {pingCount} auto-ping" # if not a DM add the username to the beginning of msg if not useDMForResponse and not isDM: