Merge branch 'main' into trap-lists

This commit is contained in:
Kelly
2024-06-26 16:11:23 -07:00
committed by GitHub
4 changed files with 37 additions and 2 deletions
+1
View File
@@ -67,6 +67,7 @@ pip install geopy
pip install maidenhead
pip install beautifulsoup4
pip install dadjokes
pip install pickle
```
dev enhancments if using visual studio
+29 -1
View File
@@ -2,17 +2,41 @@
# K7MHI Kelly Keeton 2024
from dadjokes import Dadjoke # pip install dadjokes
import pickle # pip install pickle
import os
trap_list_bbs = ("bbslist", "bbspost", "bbsread", "bbsdelete", "bbshelp")
# global message list, later we will use a database on disk
bbs_messages = [[1, "Welcome to meshBBS", "Welcome to the BBS, please post a message!"]]
bbs_messages = []
def tell_joke():
# tell a dad joke, does it need an explanationn :)
dadjoke = Dadjoke()
return dadjoke.joke
def load_bbsdb():
global bbs_messages
# load the bbs messages from the database file
if not os.path.exists('bbsdb.pkl'):
# if not, create it
bbs_messages = [[1, "Welcome to meshBBS", "Welcome to the BBS, please post a message!"]]
print ("\nSystem: Creating new bbsdb.pkl")
with open('bbsdb.pkl', 'wb') as f:
pickle.dump(bbs_messages, f)
else:
with open('bbsdb.pkl', 'rb') as f:
bbs_messages = pickle.load(f)
def save_bbsdb():
global bbs_messages
# save the bbs messages to the database file
print ("System: Saving bbsdb.pkl\n")
with open('bbsdb.pkl', 'wb') as f:
pickle.dump(bbs_messages, f)
def bbs_help():
# help message
return "BBS Commands:\n'bbslist'\n'bbspost $subject #message'\n'bbsread #'\n'bbsdelete #'"
@@ -57,3 +81,7 @@ def bbs_read_message(messageID = 0):
else:
return "Please specify a message number to read."
#initialize the bbsdb
load_bbsdb()
+5
View File
@@ -348,6 +348,11 @@ def send_message(message, ch, nodeid):
def exit_handler(signum, frame):
print("\nSystem: Closing Autoresponder")
interface.close()
print("System: Interface Closed")
print("Saving BBS Messages")
save_bbsdb()
print("System: BBS Messages Saved")
print("System: Exiting")
exit (0)
print ("\nMeshtastic Autoresponder MESH Bot CTL+C to exit\n")
+2 -1
View File
@@ -8,4 +8,5 @@ maidenhead
beautifulsoup4
dadjokes
mock
unittest
unittest
pickle