diff --git a/mesh_bot.py b/mesh_bot.py index e4ab063..bded9fa 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -42,6 +42,9 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "bbspost": lambda: handle_bbspost(message, message_from_id, deviceID), "bbsread": lambda: handle_bbsread(message), "blackjack": lambda: handleBlackJack(message, message_from_id, deviceID), + "checkin": lambda: handle_checklist(message_from_id, message), + "checkout": lambda: handle_checklist(message_from_id, message), + "checklist": lambda: handle_checklist(message_from_id, message), "clearsms": lambda: handle_sms(message_from_id, message), "cmd": lambda: help_message, "cq": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), @@ -1317,6 +1320,10 @@ async def start_rx(): logger.debug(f"System: Emergency Alert Broadcast Enabled on channels {emergencyAlertBroadcastCh}") if emergency_responder_enabled: logger.debug(f"System: Emergency Responder Enabled on channels {emergency_responder_alert_channel} for interface {emergency_responder_alert_interface}") + if qrz_hello_enabled: + logger.debug(f"System: QRZ Hello Enabled") + if checklist_enabled: + logger.debug(f"System: CheckList Module Enabled") if enableSMTP: if enableImap: logger.debug(f"System: SMTP Email Alerting Enabled using IMAP") diff --git a/modules/checklist.py b/modules/checklist.py index 293b389..96efde9 100644 --- a/modules/checklist.py +++ b/modules/checklist.py @@ -4,11 +4,11 @@ import sqlite3 from modules.log import * -trap_list_bbs = ("checkin", "checkout", "checklist", "purgein", "purgeout") +trap_list_checklist = ("checkin", "checkout", "checklist", "purgein", "purgeout") def initialize_checklist_database(): # create the database - conn = sqlite3.connect('data/checklist.db') + conn = sqlite3.connect(checklist_db) c = conn.cursor() # Check if the checkin table exists, and create it if it doesn't c.execute('''CREATE TABLE IF NOT EXISTS checkin @@ -22,7 +22,7 @@ def initialize_checklist_database(): def checkin(name, date, time, notes): # checkin a user - conn = sqlite3.connect('data/checklist.db') + conn = sqlite3.connect(checklist_db) c = conn.cursor() c.execute("INSERT INTO checkin (checkin_name, checkin_date, checkin_time, checkin_notes) VALUES (?, ?, ?, ?)", (name, date, time, notes)) conn.commit() @@ -31,7 +31,7 @@ def checkin(name, date, time, notes): def delete_checkin(checkin_id): # delete a checkin - conn = sqlite3.connect('data/checklist.db') + conn = sqlite3.connect(checklist_db) c = conn.cursor() c.execute("DELETE FROM checkin WHERE checkin_id = ?", (checkin_id,)) conn.commit() @@ -40,7 +40,7 @@ def delete_checkin(checkin_id): def checkout(name, date, time, notes): # checkout a user - conn = sqlite3.connect('data/checklist.db') + conn = sqlite3.connect(checklist_db) c = conn.cursor() c.execute("INSERT INTO checkout (checkout_name, checkout_date, checkout_time, checkout_notes) VALUES (?, ?, ?, ?)", (name, date, time, notes)) conn.commit() @@ -49,7 +49,7 @@ def checkout(name, date, time, notes): def delete_checkout(checkout_id): # delete a checkout - conn = sqlite3.connect('data/checklist.db') + conn = sqlite3.connect(checklist_db) c = conn.cursor() c.execute("DELETE FROM checkout WHERE checkout_id = ?", (checkout_id,)) conn.commit() @@ -58,7 +58,7 @@ def delete_checkout(checkout_id): def list_checkin(): # list checkins - conn = sqlite3.connect('data/checklist.db') + conn = sqlite3.connect(checklist_db) c = conn.cursor() c.execute(""" SELECT * FROM checkin diff --git a/modules/qrz.py b/modules/qrz.py index b4d4d0f..da2f82d 100644 --- a/modules/qrz.py +++ b/modules/qrz.py @@ -6,18 +6,17 @@ from modules.log import * def initalize_qrz_database(): # create the database - conn = sqlite3.connect('data/qrz.db') + conn = sqlite3.connect(qrz_db) c = conn.cursor() # Check if the qrz table exists, and create it if it doesn't c.execute('''CREATE TABLE IF NOT EXISTS qrz (qrz_id INTEGER PRIMARY KEY, qrz_call TEXT, qrz_name TEXT, qrz_qth TEXT, qrz_notes TEXT)''') conn.commit() conn.close() - logger.debug("System: Ensured data/qrz.db exists with required tables") def never_seen_before(nodeID): # check if we have seen this node before and sent a hello message - conn = sqlite3.connect('data/qrz.db') + conn = sqlite3.connect(qrz_db) c = conn.cursor() c.execute("SELECT * FROM qrz WHERE qrz_call = ?", (nodeID,)) row = c.fetchone() @@ -29,7 +28,7 @@ def never_seen_before(nodeID): def hello(nodeID, name, qth, notes): # send a hello message - conn = sqlite3.connect('data/qrz.db') + conn = sqlite3.connect(qrz_db) c = conn.cursor() c.execute("INSERT INTO qrz (qrz_call, qrz_name, qrz_qth, qrz_notes) VALUES (?, ?, ?, ?)", (nodeID, name, qth, notes)) conn.commit() diff --git a/modules/settings.py b/modules/settings.py index 0e7af76..c0160a1 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -91,6 +91,14 @@ if 'smtp' not in config: config['smtp'] = {'sysopEmails': '', 'enableSMTP': 'False', 'enableImap': 'False'} config.write(open(config_file, 'w')) +if 'checklist' not in config: + config['checklist'] = {'enabled': 'False', 'checklist_db': 'data/checklist.db'} + config.write(open(config_file, 'w')) + +if 'qrz' not in config: + config['qrz'] = {'enabled': 'False', 'qrz_db': 'data/qrz.db'} + config.write(open(config_file, 'w')) + # interface1 settings interface1_type = config['interface'].get('type', 'serial') port1 = config['interface'].get('port', '') @@ -260,7 +268,15 @@ try: bbs_admin_list = config['bbs'].get('bbs_admin_list', '').split(',') bbs_link_enabled = config['bbs'].getboolean('bbslink_enabled', False) bbs_link_whitelist = config['bbs'].get('bbslink_whitelist', '').split(',') + + # checklist + checklist_enabled = config['checklist'].getboolean('enabled', False) + checklist_db = config['checklist'].get('checklist_db', 'data/checklist.db') + # qrz hello + qrz_hello_enabled = config['qrz'].getboolean('enabled', False) + qrz_db = config['qrz'].get('qrz_db', 'data/qrz.db') + # E-Mail Settings sysopEmails = config['smtp'].get('sysopEmails', '').split(',') enableSMTP = config['smtp'].getboolean('enableSMTP', False) diff --git a/modules/system.py b/modules/system.py index b1376db..419ae58 100644 --- a/modules/system.py +++ b/modules/system.py @@ -190,6 +190,18 @@ if store_forward_enabled: trap_list = trap_list + ("messages",) help_message = help_message + ", messages" +# QRZ Configuration +if qrz_hello_enabled: + from modules.qrz import * # from the spudgunman/meshing-around repo + #trap_list = trap_list + trap_list_qrz # items qrz, qrz?, qrzcall + #help_message = help_message + ", qrz" + +# CheckList Configuration +if checklist_enabled: + from modules.checklist import * # from the spudgunman/meshing-around repo + trap_list = trap_list + trap_list_checklist # items checkin, checkout, checklist, purgein, purgeout + help_message = help_message + ", checkin, checkout" + # Radio Monitor Configuration if radio_detection_enabled: from modules.radio import * # from the spudgunman/meshing-around repo