diff --git a/README.md b/README.md index 171aa78..dd514e0 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,17 @@ # meshing-around Random Mesh Scripts for BBS activities for use with Meshtastic nodes -## pong-bot.sh ![alt text](etc/pong-bot.jpg "Example Use") -Little bot which will trap keywords like ping and respond on a DM with pong. The script will also monitor the group channels for keywords to trap on. you can also `Ping @Data to Echo` as a example for further processing. +## mesh_bot.sh +The feature rich bot, normally requires internet for full functionality. These responder bots will trap keywords like, ping and respond on a DM(direct Message) with, pong! The script will also monitor the group channels for keywords to trap on. You can also `Ping @Data to Echo` as a example for further processing. -other features -- `motd` or to set the message `motd $New Message Of the day` -- `lheard` returns the last 5 heard nodes with SNR, can also use `sitrep` -- `cmd` returns the list of commands (the help message) +Along with network testing these this bot has a lot of other features like simple messaging you can leave for another device, when seen it can send the message for you. -## mesh-bot.sh +The bot also is capable of dual radio/nodes so you can monitor two networks at the same time and send messages to nodes using the `bbspost @nodeNumber #message` function. + +There is a small messageboard to fit in the constraints of Meshtastic for listing bulletin messages with `bbspost $subject #message` -Alternate bot, adds internet and other telemetry data which goes beyond just ping - Various solar details for radio propagation - `sun` and `moon` return info on rise and set local time @@ -32,6 +30,12 @@ Alternate bot, adds internet and other telemetry data which goes beyond just pin - `wxa` and `wxalert` returns NOAA alerts. short title or expanded details - `joke` tells a joke - `messages` Replay the last messages heard, like Store and Forward + - `motd` or to set the message `motd $New Message Of the day` + - `lheard` returns the last 5 heard nodes with SNR, can also use `sitrep` + - `cmd` returns the list of commands (the help message) + +## pong_bot.sh +Stripped down bot, mostly around for archive purposes. The mesh-bot enhanced modules can be disabled by config. ## Install - Clone the project with `git clone https://github.com/spudgunman/meshing-around` @@ -39,7 +43,7 @@ Alternate bot, adds internet and other telemetry data which goes beyond just pin - `launch.sh` will activate and launch the app in the venv if built ### Configurations -Some config is via code see `modules/settings.py`, converting to `config.ini` set the appropriate interface for your method (serial/ble/tcp). The config.template can be used to make a new config.ini +copy the [`config.template`](config.template) to `config.ini` set the appropriate interface for your method (serial/ble/tcp). ``` #config.ini @@ -59,7 +63,9 @@ type = serial enabled = False ``` -The following pair of settings determine how to respond, default action is to not spam the default channel. Setting DM_ONLY will force all DM which may not be wanted. Setting the Default channel is the channel which wont be spammed by the bot. +The following pair of settings determine how to respond, default action is to not spam the default channel. Setting `respond_by_dm_only` will force all messaged to DM which may not be wanted. Setting the value to True will allow responses in the channel for all to see. + +Setting the Default channel, is the channel which wont be spammed by the bot. It's the public default channel 0 on new Meshtastic firmware. Anti-Spam is hardcoded into the responder to prevent abuse of public channel. ``` [general] respond_by_dm_only = True @@ -72,11 +78,10 @@ Modules can be disabled or enabled enabled = False [general] -DadJokes = True -StoreForward = True -StoreLimit = 3 # The number of StoreForward messages to retain +DadJokes = False +StoreForward = False ``` -The BBS has admin and block lists, see the modules/bbstools.py for details +The BBS has admin and block lists, see the [`config.template`](config.template) # requirements can also be installed with `pip install -r requirements.txt` @@ -85,7 +90,7 @@ can also be installed with `pip install -r requirements.txt` pip install meshtastic pip install pubsub ``` -mesh-bot enhancments +mesh-bot enhancements ``` pip install pyephem @@ -106,3 +111,4 @@ GitHub user https://github.com/PiDiBi Discord and Mesh user Cisien, and github Hailo1999, for testing and ideas! + diff --git a/modules/locationdata.py b/modules/locationdata.py index d09859b..ebcea58 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -33,7 +33,7 @@ def get_tide(lat=0, lon=0): return NO_DATA_NOGPS station_lookup_url = "https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/tidepredstations.json?lat=" + str(lat) + "&lon=" + str(lon) + "&radius=50" try: - station_data = requests.get(station_lookup_url, timeout=URL_TIMEOUT) + station_data = requests.get(station_lookup_url, timeout=urlTimeoutSeconds) if station_data.ok: station_json = station_data.json() else: @@ -52,7 +52,7 @@ def get_tide(lat=0, lon=0): station_url += "&clock=24hour" try: - station_data = requests.get(station_url, timeout=URL_TIMEOUT) + station_data = requests.get(station_url, timeout=urlTimeoutSeconds) if not station_data.ok: return ERROR_FETCHING_DATA except (requests.exceptions.RequestException): @@ -92,7 +92,7 @@ def get_weather(lat=0, lon=0, unit=0): weather_url += "&unit=1" try: - weather_data = requests.get(weather_url, timeout=URL_TIMEOUT) + weather_data = requests.get(weather_url, timeout=urlTimeoutSeconds) if not weather_data.ok: return ERROR_FETCHING_DATA except (requests.exceptions.RequestException): @@ -112,7 +112,7 @@ def get_weather(lat=0, lon=0, unit=0): # shrink the text line = abbreviate_weather(row.text) # only grab a few days of weather - if len(weather.split("\n")) < DAYS_OF_WEATHER: + if len(weather.split("\n")) < forecastDuration: weather += line + "\n" # trim off last newline weather = weather[:-1] @@ -187,7 +187,7 @@ def getWeatherAlerts(lat=0, lon=0): #alert_url = "https://api.weather.gov/alerts/active.atom?area=WA" try: - alert_data = requests.get(alert_url, timeout=URL_TIMEOUT) + alert_data = requests.get(alert_url, timeout=urlTimeoutSeconds) if not alert_data.ok: return ERROR_FETCHING_DATA except (requests.exceptions.RequestException): @@ -215,7 +215,7 @@ def getWeatherAlerts(lat=0, lon=0): alerts = abbreviate_weather(alerts) # return the first ALERT_COUNT alerts - data = "\n".join(alerts.split("\n")[:ALERT_COUNT]), alert_num + data = "\n".join(alerts.split("\n")[:numWxAlerts]), alert_num return data def getActiveWeatherAlertsDetail(lat=0, lon=0): @@ -228,7 +228,7 @@ def getActiveWeatherAlertsDetail(lat=0, lon=0): #alert_url = "https://api.weather.gov/alerts/active.atom?area=WA" try: - alert_data = requests.get(alert_url, timeout=URL_TIMEOUT) + alert_data = requests.get(alert_url, timeout=urlTimeoutSeconds) if not alert_data.ok: return ERROR_FETCHING_DATA except (requests.exceptions.RequestException): @@ -252,7 +252,7 @@ def getActiveWeatherAlertsDetail(lat=0, lon=0): alerts = abbreviate_weather(alerts) # trim the alerts to the first ALERT_COUNT - alerts = alerts.split("\n***\n")[:ALERT_COUNT] + alerts = alerts.split("\n***\n")[:numWxAlerts] if alerts == "" or alerts == ['']: return ERROR_FETCHING_DATA diff --git a/modules/settings.py b/modules/settings.py index 3fd7849..d8a460d 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -63,8 +63,8 @@ bbsdb = config['bbs'].get('bbsdb', 'bbsdb.pkl') dad_jokes_enabled = config['general'].getboolean('DadJokes', False) store_forward_enabled = config['general'].getboolean('StoreForward', False) config['general'].get('motd', MOTD) -URL_TIMEOUT = config['general'].getint('URL_TIMEOUT', 10) # default 10 seconds -DAYS_OF_WEATHER = config['general'].getint('DAYS_OF_WEATHER', 4) # default days of weather -ALERT_COUNT = config['general'].getint('ALERT_COUNT', 2) # default 2 alerts +urlTimeoutSeconds = config['general'].getint('URL_TIMEOUT', 10) # default 10 seconds +forecastDuration = config['general'].getint('DAYS_OF_WEATHER', 4) # default days of weather +numWxAlerts = config['general'].getint('ALERT_COUNT', 2) # default 2 alerts bbs_ban_list = config['bbs'].get('ban_list', '').split(',') bbs_admin_list = config['bbs'].get('admin_list', '').split(',') \ No newline at end of file diff --git a/modules/solarconditions.py b/modules/solarconditions.py index b158fb1..7dc559a 100644 --- a/modules/solarconditions.py +++ b/modules/solarconditions.py @@ -14,7 +14,7 @@ trap_list_solarconditions = ("sun", "solar", "hfcond") def hf_band_conditions(): # ham radio HF band conditions hf_cond = "" - band_cond = requests.get("https://www.hamqsl.com/solarxml.php", timeout=URL_TIMEOUT) + band_cond = requests.get("https://www.hamqsl.com/solarxml.php", timeout=urlTimeoutSeconds) if(band_cond.ok): solarxml = xml.dom.minidom.parseString(band_cond.text) for i in solarxml.getElementsByTagName("band"): @@ -27,7 +27,7 @@ def hf_band_conditions(): def solar_conditions(): # radio related solar conditions from hamsql.com solar_cond = "" - solar_cond = requests.get("https://www.hamqsl.com/solarxml.php", timeout=URL_TIMEOUT) + solar_cond = requests.get("https://www.hamqsl.com/solarxml.php", timeout=urlTimeoutSeconds) if(solar_cond.ok): solar_xml = xml.dom.minidom.parseString(solar_cond.text) for i in solar_xml.getElementsByTagName("solardata"): @@ -45,7 +45,7 @@ def solar_conditions(): def drap_xray_conditions(): # DRAP X-ray flux conditions, from NOAA direct drap_cond = "" - drap_cond = requests.get("https://services.swpc.noaa.gov/text/drap_global_frequencies.txt", timeout=URL_TIMEOUT) + drap_cond = requests.get("https://services.swpc.noaa.gov/text/drap_global_frequencies.txt", timeout=urlTimeoutSeconds) if(drap_cond.ok): drap_list = drap_cond.text.split('\n') x_filter = '# X-RAY Message :'