From bb0f923155bc164a0c8505cfe8702cb1fe11be2e Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 31 Oct 2024 16:38:16 -0700 Subject: [PATCH 1/4] bbslink first attempt at giving BBS link over the air --- mesh_bot.py | 5 +++++ modules/bbstools.py | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 97506a4..e973537 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -28,9 +28,11 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "ack": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM), "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), "askai": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), + "bbslink": lambda: bbs_sync_posts(message, message_from_id, deviceID), "bbsdelete": lambda: handle_bbsdelete(message, message_from_id), "bbshelp": bbs_help, "bbsinfo": lambda: get_bbs_stats(), + "bbslink": lambda: bbs_sync_posts(message, message_from_id, deviceID), "bbslist": bbs_list_messages, "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), "bbsread": lambda: handle_bbsread(message), @@ -1083,6 +1085,9 @@ async def start_rx(): # Send the MOTD every day at 13:00 using send_message function to channel 2 on device 1 #schedule.every().day.at("13:00").do(lambda: send_message(MOTD, 2, 0, 1)) + + # Send bbslink looking for peers every other day at 10:00 using send_message function to channel 0 on device 1 + #schedule.every(2).days.at("10:00").do(lambda: send_message("bbslink MeshBot looking for peers", 0, 0, 1)) # logger.debug("System: Starting the broadcast scheduler") diff --git a/modules/bbstools.py b/modules/bbstools.py index 5628327..4a28cb6 100644 --- a/modules/bbstools.py +++ b/modules/bbstools.py @@ -4,7 +4,7 @@ import pickle # pip install pickle from modules.log import * -trap_list_bbs = ("bbslist", "bbspost", "bbsread", "bbsdelete", "bbshelp", "bbsinfo") +trap_list_bbs = ("bbslist", "bbspost", "bbsread", "bbsdelete", "bbshelp", "bbsinfo", "bbslink", "bbsack") # global message list, later we will use a pickle on disk bbs_messages = [] @@ -156,6 +156,23 @@ def bbs_delete_dm(toNode, message): return "System: cleared mail for" + str(toNode) return "System: No DM found for node " + str(toNode) +def bbs_sync_posts(input, peerNode, RxNode): + # respond when another bot asks for the bbs posts to sync + + # Respond wth the first message + message = bbs_messages[0] + + if "bbslink" in input: + # split to get the messageID + lastAck = int(input.split(" ")[1]) + # send the next highest messageID + return "bbspost " + str(bbs_messages[lastAck + 1][0]) + + return message + + + + #initialize the bbsdb's load_bbsdb() load_bbsdm() From e1b3dd311ff3bf3f15165a959fa1d3261512b2a0 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 31 Oct 2024 16:42:09 -0700 Subject: [PATCH 2/4] Update bbstools.py --- modules/bbstools.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/bbstools.py b/modules/bbstools.py index 4a28cb6..5057bfe 100644 --- a/modules/bbstools.py +++ b/modules/bbstools.py @@ -77,6 +77,12 @@ def bbs_post_message(subject, message, fromNode): if str(fromNode) in bbs_ban_list: logger.warning(f"System: Naughty node {fromNode}, tried to post a message: {subject}, {message} and was dropped.") return "Message posted. ID is: " + str(messageID) + + # validate not a duplicate message + for msg in bbs_messages: + if msg[1] == subject and msg[2] == message: + messageID = msg[0] + return "Message posted. ID is: " + str(messageID) # append the message to the list bbs_messages.append([messageID, subject, message, fromNode]) @@ -157,20 +163,26 @@ def bbs_delete_dm(toNode, message): return "System: No DM found for node " + str(toNode) def bbs_sync_posts(input, peerNode, RxNode): + messageID = 0 # respond when another bot asks for the bbs posts to sync + if "bbslink" in input.lower(): + if "$" in input and "#" in input: + #store the message + subject = input.split("$")[1].split("#")[0] + body = input.split("#")[1] + bbs_post_message(subject, body, peerNode) + messageID = input.split(" ")[1] + return f"bbsack {messageID}" + elif "bbsack" in input.lower(): + # increment the messageID + ack = int(input.split(" ")[1]) + messageID = int(ack) + 1 - # Respond wth the first message - message = bbs_messages[0] - - if "bbslink" in input: - # split to get the messageID - lastAck = int(input.split(" ")[1]) - # send the next highest messageID - return "bbspost " + str(bbs_messages[lastAck + 1][0]) - - return message - - + # send message + if messageID < len(bbs_messages): + return f"bbslink {messageID} ${bbs_messages[messageID][1]} #{bbs_messages[messageID][2]}" + else: + logger.debug("System: bbslink sync complete with peer " + str(peerNode)) #initialize the bbsdb's From 4e518758e5fcb788dd2eaf02f9f0f3a0d4919518 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 31 Oct 2024 16:56:43 -0700 Subject: [PATCH 3/4] Update bbstools.py --- modules/bbstools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bbstools.py b/modules/bbstools.py index 5057bfe..87dc368 100644 --- a/modules/bbstools.py +++ b/modules/bbstools.py @@ -80,7 +80,7 @@ def bbs_post_message(subject, message, fromNode): # validate not a duplicate message for msg in bbs_messages: - if msg[1] == subject and msg[2] == message: + if msg[1].strip().lower() == subject.strip().lower() and msg[2].strip().lower() == message.strip().lower(): messageID = msg[0] return "Message posted. ID is: " + str(messageID) From 952659198c9e4cbf54f6b26a7290b0b261a6bbf6 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 5 Nov 2024 07:45:19 -0800 Subject: [PATCH 4/4] fixes --- mesh_bot.py | 2 ++ modules/games/joke.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index e973537..787e025 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -162,6 +162,8 @@ def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM): msg = "๐Ÿ›‘ auto-ping" try: pingCount = int(message.split(" ")[1]) + if pingCount == 123 or pingCount == 1234: + pingCount = 1 if pingCount > 51: pingCount = 50 except: diff --git a/modules/games/joke.py b/modules/games/joke.py index 1c08459..2e70f36 100644 --- a/modules/games/joke.py +++ b/modules/games/joke.py @@ -78,7 +78,7 @@ def tableOfContents(): 'whale': '๐Ÿ‹', 'dolphin': '๐Ÿฌ', 'fish': '๐ŸŸ', 'blowfish': '๐Ÿก', 'shark': '๐Ÿฆˆ', 'octopus': '๐Ÿ™', 'shell': '๐Ÿš', 'crab': '๐Ÿฆ€', 'lobster': '๐Ÿฆž', 'shrimp': '๐Ÿฆ', 'squid': '๐Ÿฆ‘', 'snail': '๐ŸŒ', 'butterfly': '๐Ÿฆ‹', 'bee': '๐Ÿ', 'beetle': '๐Ÿž', 'ant': '๐Ÿœ', 'cricket': '๐Ÿฆ—', 'spider': '๐Ÿ•ท๏ธ', 'scorpion': '๐Ÿฆ‚', 'mosquito': '๐ŸฆŸ', 'microbe': '๐Ÿฆ ', 'locomotive': '๐Ÿš‚', 'arm': '๐Ÿ’ช', 'leg': '๐Ÿฆต', 'sponge': '๐Ÿงฝ', 'toothbrush': '๐Ÿชฅ', 'broom': '๐Ÿงน', 'basket': '๐Ÿงบ', 'roll of paper': '๐Ÿงป', 'bucket': '๐Ÿชฃ', 'soap': '๐Ÿงผ', 'toilet paper': '๐Ÿงป', 'shower': '๐Ÿšฟ', 'bathtub': '๐Ÿ›', 'razor': '๐Ÿช’', 'lotion': '๐Ÿงด', - 'letter': 'โœ‰๏ธ', 'envelope': 'โœ‰๏ธ', 'mail': '๐Ÿ“ฌ', 'post': '๐Ÿ“ฎ', 'golf': 'โ›ณ๏ธ', 'golfing': 'โ›ณ๏ธ', 'office': '๐Ÿข', 'work': '๐Ÿ’ผ', 'meeting': '๐Ÿ“…', 'presentation': '๐Ÿ“Š', 'report': '๐Ÿ“„', 'document': '๐Ÿ“„', + 'letter': 'โœ‰๏ธ', 'envelope': 'โœ‰๏ธ', 'mail': '๐Ÿ“ฌ', 'post': '๐Ÿ“ฎ', 'golf': 'โ›ณ๏ธ', 'golfing': 'โ›ณ๏ธ', 'office': '๐Ÿข', 'meeting': '๐Ÿ“…', 'presentation': '๐Ÿ“Š', 'report': '๐Ÿ“„', 'document': '๐Ÿ“„', 'file': '๐Ÿ“', 'folder': '๐Ÿ“‚', 'sports': '๐Ÿ…', 'athlete': '๐Ÿƒ', 'competition': '๐Ÿ†', 'race': '๐Ÿ', 'tournament': '๐Ÿ†', 'champion': '๐Ÿ†', 'medal': '๐Ÿ…', 'victory': '๐Ÿ†', 'win': '๐Ÿ†', 'lose': '๐Ÿ˜ž', 'draw': '๐Ÿค', 'team': '๐Ÿ‘ฅ', 'player': '๐Ÿ‘ค', 'coach': '๐Ÿ‘จโ€๐Ÿซ', 'referee': '๐Ÿง‘โ€โš–๏ธ', 'stadium': '๐ŸŸ๏ธ', 'arena': '๐ŸŸ๏ธ', 'field': '๐ŸŸ๏ธ', 'court': '๐ŸŸ๏ธ', 'track': '๐ŸŸ๏ธ', 'gym': '๐Ÿ‹๏ธ', 'fitness': '๐Ÿ‹๏ธ', 'exercise': '๐Ÿ‹๏ธ', 'workout': '๐Ÿ‹๏ธ', 'training': '๐Ÿ‹๏ธ', 'practice': '๐Ÿ‹๏ธ', 'game': '๐ŸŽฎ', 'match': '๐ŸŽฎ', 'score': '๐Ÿ…', 'goal': '๐Ÿฅ…', 'point': '๐Ÿ…', 'basket': '๐Ÿ€', 'home run': 'โšพ๏ธ', 'strike': '๐ŸŽณ', 'spare': '๐ŸŽณ', 'frame': '๐ŸŽณ',