Skip to content

Commit

Permalink
Merge pull request #85 from SpudGunMan/lab
Browse files Browse the repository at this point in the history
BBS LiNK
  • Loading branch information
SpudGunMan authored Nov 7, 2024
2 parents ab86f02 + 9526591 commit 432b5a7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
7 changes: 7 additions & 0 deletions mesh_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -160,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:
Expand Down Expand Up @@ -1083,6 +1087,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")
Expand Down
31 changes: 30 additions & 1 deletion modules/bbstools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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].strip().lower() == subject.strip().lower() and msg[2].strip().lower() == message.strip().lower():
messageID = msg[0]
return "Message posted. ID is: " + str(messageID)

# append the message to the list
bbs_messages.append([messageID, subject, message, fromNode])
Expand Down Expand Up @@ -156,6 +162,29 @@ 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):
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

# 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
load_bbsdb()
load_bbsdm()
2 changes: 1 addition & 1 deletion modules/games/joke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '๐ŸŽณ',
Expand Down

0 comments on commit 432b5a7

Please sign in to comment.