From 049c0d5ad7c784990011bc3a4a227f4789b9349a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 2 Dec 2024 16:05:14 -0800 Subject: [PATCH] bbsLinkEnhancments --- README.md | 5 +++++ config.template | 4 ++++ modules/bbstools.py | 9 ++++++++- modules/settings.py | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be3a1a3..a5ba158 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,11 @@ The scheduler also handles the BBL Link Brodcast message, this would be an esxam # Send bbslink looking for peers every other day at 10:00 using send_message function to channel 8 on device 1 schedule.every(2).days.at("10:00").do(lambda: send_message("bbslink MeshBot looking for peers", 8, 0, 1)) ``` +```ini +bbslink_enabled = True +# list of whitelisted nodes numbers ex: 2813308004,4258675309 empty list allows all +bbslink_whitelist = +``` ### MQTT Notes There is no direct support for MQTT in the code, however, reports from Discord are that using [meshtasticd](https://meshtastic.org/docs/hardware/devices/linux-native-hardware/) with no radio and attaching the bot to the software node, which is MQTT-linked, allows routing. There also seems to be a quicker way to enable MQTT by having your bot node with the enabled [serial](https://meshtastic.org/docs/configuration/module/serial/) module with echo enabled and MQTT uplink and downlink. These two methods have been mentioned as allowing MQTT routing for the project. diff --git a/config.template b/config.template index b3f7ae9..fb9d2ec 100644 --- a/config.template +++ b/config.template @@ -94,6 +94,10 @@ enabled = True bbs_ban_list = # list of admin nodes numbers ex: 2813308004,4258675309 bbs_admin_list = +# enable bbs synchronization with other nodes +bbslink_enabled = False +# list of whitelisted nodes numbers ex: 2813308004,4258675309 empty list allows all +bbslink_whitelist = # location module [location] diff --git a/modules/bbstools.py b/modules/bbstools.py index c216dbc..3c7db3c 100644 --- a/modules/bbstools.py +++ b/modules/bbstools.py @@ -165,6 +165,10 @@ def bbs_delete_dm(toNode, message): def bbs_sync_posts(input, peerNode, RxNode): messageID = 0 + # check if the bbs link is enabled + if bbs_link_enabled == False or (bbs_link_enabled == True and str(RxNode) not in bbs_link_whitelsit): + return "System: BBS Link is disabled for your node." + # respond when another bot asks for the bbs posts to sync if "bbslink" in input.lower(): if "$" in input and "#" in input: @@ -180,8 +184,11 @@ def bbs_sync_posts(input, peerNode, RxNode): messageID = int(ack) + 1 # send message with delay to keep chutil happy - time.sleep(1 + responseDelay) if messageID < len(bbs_messages): + time.sleep(5 + responseDelay) + # every 5 messages add extra delay + if messageID % 5 == 0: + time.sleep(10 + responseDelay) return f"bbslink {messageID} ${bbs_messages[messageID][1]} #{bbs_messages[messageID][2]}" else: logger.debug("System: bbslink sync complete with peer " + str(peerNode)) diff --git a/modules/settings.py b/modules/settings.py index 97a0bab..a2ad703 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -156,6 +156,8 @@ try: bbsdb = config['bbs'].get('bbsdb', 'data/bbsdb.pkl') bbs_ban_list = config['bbs'].get('bbs_ban_list', '').split(',') bbs_admin_list = config['bbs'].get('bbs_admin_list', '').split(',') + bbs_link_enabled = config['bbs'].getboolean('bbslink_enabled', False) + bbs_link_whitelsit = config['bbs'].get('bbslink_whitelist', '').split(',') # repeater repeater_enabled = config['repeater'].getboolean('enabled', False)