mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-03-28 17:32:36 +01:00
save bbddb
This commit is contained in:
@@ -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
bbstools.py
29
bbstools.py
@@ -2,26 +2,36 @@
|
||||
# K7MHI Kelly Keeton 2024
|
||||
|
||||
from dadjokes import Dadjoke # pip install dadjokes
|
||||
import pickle # pip install pickle
|
||||
import os
|
||||
|
||||
# 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!"]]
|
||||
# global message list
|
||||
bbs_messages = []
|
||||
|
||||
def tell_joke():
|
||||
# tell a dad joke, does it need an explanationn :)
|
||||
dadjoke = Dadjoke()
|
||||
return dadjoke.joke
|
||||
|
||||
def create_bbsdb():
|
||||
# create a database file for the bbs messages
|
||||
pass
|
||||
|
||||
def load_bbsdb():
|
||||
global bbs_messages
|
||||
# load the bbs messages from the database file
|
||||
pass
|
||||
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
|
||||
pass
|
||||
print ("System: Saving bbsdb.pkl\n")
|
||||
with open('bbsdb.pkl', 'wb') as f:
|
||||
pickle.dump(bbs_messages, f)
|
||||
|
||||
def bbs_help():
|
||||
# help message
|
||||
@@ -67,5 +77,6 @@ def bbs_read_message(messageID = 0):
|
||||
else:
|
||||
return "Please specify a message number to read."
|
||||
|
||||
|
||||
#initialize the bbsdb
|
||||
load_bbsdb()
|
||||
|
||||
|
||||
@@ -343,6 +343,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")
|
||||
|
||||
@@ -8,4 +8,5 @@ maidenhead
|
||||
beautifulsoup4
|
||||
dadjokes
|
||||
mock
|
||||
unittest
|
||||
unittest
|
||||
pickle
|
||||
Reference in New Issue
Block a user