From 0ad01c1caf87b80a722fcfeb1198a692515433c0 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 9 Jul 2024 11:40:17 -0700 Subject: [PATCH] Update mesh_bot.py --- mesh_bot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 796715b..a88daa0 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -33,6 +33,7 @@ welcome_message = "MeshBot, here for you like a friend who is not. Try sending: help_message = "CMD?: ping, motd, sitrep, joke, sun, hfcond, solar, moon, tide, whereami, wx, wxc, wxa, bbslist, bbshelp" MOTD = "Thanks for using PongBOT! Have a good day!" # Message of the Day RESPOND_BY_DM_ONLY = True # Set to True to respond messages via DM only (keeps the channel clean) +DEFAULT_CHANNEL = 0 # Default channel on your node, also known as "public channel" 0 on new devices #Get the node number of the device, check if the device is connected try: @@ -236,7 +237,12 @@ def onReceive(packet, interface): send_message(auto_response(message_string,snr,rssi,hop,message_from_id),channel_number,message_from_id) else: # or respond to channel message on the channel itself - send_message(auto_response(message_string,snr,rssi,message_from_id),channel_number,0) + if channel_number == DEFAULT_CHANNEL: + print(f"{log_timestamp()} System: Warning spamming default channel") + #warning user spamming default channel + send_message(auto_response(message_string,snr,rssi,message_from_id),channel_number,0) + else: + send_message(auto_response(message_string,snr,rssi,message_from_id),channel_number,0) else: print(f"{log_timestamp()} System: Ignoring incoming channel {channel_number}: {message_string} From: {get_name_from_number(message_from_id)}") @@ -348,7 +354,7 @@ def send_message(message, ch, nodeid): message_list.append(line) line = word + ' ' message_list.append(line) # needed add contents of the last 'line' into the list - #message_list = [x.replace(' NEWLINE ', '\n') for x in message_list] # put back the newlines + #message_list = [x.replace('NEWLINE', '\n') for x in message_list] # put back the newlines for m in message_list: if nodeid == 0: