From a6603d4d488cd6abda7bdfd2bc3fa9c7bee0ba04 Mon Sep 17 00:00:00 2001 From: David Bures <12524436+PiDiBi@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:24:17 -0700 Subject: [PATCH] make trap list configurable --- bbstools.py | 4 ++-- locationdata.py | 3 +++ mesh_bot.py | 13 +++++++++---- solarconditions.py | 4 +++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/bbstools.py b/bbstools.py index bac7d4c..e13afbb 100644 --- a/bbstools.py +++ b/bbstools.py @@ -3,6 +3,8 @@ from dadjokes import Dadjoke # pip install dadjokes +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!"]] @@ -55,5 +57,3 @@ def bbs_read_message(messageID = 0): else: return "Please specify a message number to read." - - diff --git a/locationdata.py b/locationdata.py index 318e581..5ed27f7 100644 --- a/locationdata.py +++ b/locationdata.py @@ -13,6 +13,8 @@ DAYS_OF_WEATHER = 2 # weather forecast days, the first two rows are today and to NO_DATA_NOGPS = "no location data: does your device have GPS?" ERROR_FETCHING_DATA = "error fetching data" +trap_list_location = ("whereami", "tide", "moon", "wx", "wxc") + def where_am_i(lat=0, lon=0): whereIam = "" if float(lat) == 0 and float(lon) == 0: @@ -157,3 +159,4 @@ def replace_weather(row): line = line.replace(key, value) return line + diff --git a/mesh_bot.py b/mesh_bot.py index 1fa3931..5a46965 100644 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -12,16 +12,21 @@ from datetime import datetime from solarconditions import * # from the spudgunman/meshing-around repo from locationdata import * # from the spudgunman/meshing-around repo -from bbstools import * # from the spudgunman/meshing-around repo +from bbstools import * +from solarconditions import trap_list_conditions # from the spudgunman/meshing-around repo # Uncomment the interface you want to use depending on your device connection interface = meshtastic.serial_interface.SerialInterface() #serial interface #interface=meshtastic.tcp_interface.TCPInterface(hostname="192.168.0.1") # IP of your device #interface=meshtastic.ble_interface.BLEInterface("AA:BB:CC:DD:EE:FF") # BLE interface -#A list of strings to trap and respond to -trap_list = ("ping", "ack", "testing", "pong", "motd", "help", "sun", "solar", "hfcond", "lheard", "sitrep", \ - "whereami", "tide", "moon", "wx", "wxc", "joke", "bbslist", "bbspost", "bbsread", "bbsdelete", "bbshelp") +# A basic list of strings to trap and respond to +trap_list = ("ping", "ack", "testing", "pong", "motd", "help", "lheard", "sitrep", "joke") + +# join all lists, comment out unwanted funtionality, defined in corresponding files/modules +trap_list = trap_list + trap_list_location +trap_list = trap_list + trap_list_conditions +trap_list = trap_list + trap_list_bbs welcome_message = "MeshBot, here for you like a friend who is not. Try sending: ping @foo or, help" help_message = "Commands are: ack, hfcond, joke, Lheard, moon, motd, ping, solar, sun, tide, whereami, wx, bbshelp" diff --git a/solarconditions.py b/solarconditions.py index 3644932..8d4866a 100644 --- a/solarconditions.py +++ b/solarconditions.py @@ -14,6 +14,8 @@ LONGITUDE = -123.0 URL_TIMEOUT = 10 # wait time for URL requests +trap_list_conditions = ("sun", "solar", "hfcond") + def hf_band_conditions(): # ham radio HF band conditions hf_cond = "" @@ -123,4 +125,4 @@ def get_moon(lat=0, lon=0): "\nPhase:" + moon_table['phase'] + " @:" + str('{0:.2f}'.format(moon_table['illumination'])) + "%" \ + "\nFull Moon:" + moon_table['next_full_moon'] + "\nNew Moon:" + moon_table['next_new_moon'] - return moon_data \ No newline at end of file + return moon_data