From 00ba7f5ef5de5ddfe95bf6c0e6a31217e4c11372 Mon Sep 17 00:00:00 2001 From: David Bures <12524436+PiDiBi@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:54:02 -0700 Subject: [PATCH 1/6] less days of weather to avoid splitting which is not working good --- locationdata.py | 2 +- mesh_bot.py | 0 pong_bot.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 mesh_bot.py mode change 100755 => 100644 pong_bot.py diff --git a/locationdata.py b/locationdata.py index e51df4a..318e581 100644 --- a/locationdata.py +++ b/locationdata.py @@ -8,7 +8,7 @@ import requests # pip install requests import bs4 as bs # pip install beautifulsoup4 URL_TIMEOUT = 10 # wait time for URL requests -DAYS_OF_WEATHER = 4 # weather forecast days, the first two rows are today and tonight +DAYS_OF_WEATHER = 2 # weather forecast days, the first two rows are today and tonight # unified error messages to be able to test them from tests NO_DATA_NOGPS = "no location data: does your device have GPS?" ERROR_FETCHING_DATA = "error fetching data" diff --git a/mesh_bot.py b/mesh_bot.py old mode 100755 new mode 100644 diff --git a/pong_bot.py b/pong_bot.py old mode 100755 new mode 100644 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 2/6] 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 From fe3cd7ae8826855b3f589570f6776bee8d8d3970 Mon Sep 17 00:00:00 2001 From: David Bures <12524436+PiDiBi@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:26:42 -0700 Subject: [PATCH 3/6] fix help message --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 5a46965..e568bea 100644 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -29,7 +29,7 @@ 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" +help_message = "Commands are: " + ", ".join(trap_list, ', ') MOTD = "Thanks for using PongBOT! Have a good day!" # Message of the Day RESPOND_BY_DM_ONLY = True # Set to True to respond messages via DM only (keeps the channel clean) From f763d77753e4ac2793411c277576542e8d7b4209 Mon Sep 17 00:00:00 2001 From: David Bures <12524436+PiDiBi@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:28:01 -0700 Subject: [PATCH 4/6] fixes --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index e568bea..73db2f4 100644 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -29,7 +29,7 @@ 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: " + ", ".join(trap_list, ', ') +help_message = "Commands are: " + ", ".join(trap_list) MOTD = "Thanks for using PongBOT! Have a good day!" # Message of the Day RESPOND_BY_DM_ONLY = True # Set to True to respond messages via DM only (keeps the channel clean) From 0dd234023be6665cd031db4d150454e12480ad7d Mon Sep 17 00:00:00 2001 From: David Bures <12524436+PiDiBi@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:29:16 -0700 Subject: [PATCH 5/6] disable bbs --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 73db2f4..af8b22e 100644 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -26,7 +26,7 @@ trap_list = ("ping", "ack", "testing", "pong", "motd", "help", "lheard", "sitre # 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 +#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: " + ", ".join(trap_list) From 97bf75a6d27a9d6321566a9af1dfa1ddb4950f2c Mon Sep 17 00:00:00 2001 From: David Bures <12524436+PiDiBi@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:33:50 -0700 Subject: [PATCH 6/6] weather back to 4 lines --- locationdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locationdata.py b/locationdata.py index 5ed27f7..6203906 100644 --- a/locationdata.py +++ b/locationdata.py @@ -8,7 +8,7 @@ import requests # pip install requests import bs4 as bs # pip install beautifulsoup4 URL_TIMEOUT = 10 # wait time for URL requests -DAYS_OF_WEATHER = 2 # weather forecast days, the first two rows are today and tonight +DAYS_OF_WEATHER = 4 # weather forecast days, the first two rows are today and tonight # unified error messages to be able to test them from tests NO_DATA_NOGPS = "no location data: does your device have GPS?" ERROR_FETCHING_DATA = "error fetching data"