From e17999a2d654edd318416e311639ebcb4e876796 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 8 Aug 2024 23:04:51 -0700 Subject: [PATCH 1/7] numpy.. --- README.md | 4 ++++ requirements.txt | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b2a5b7..47f2d36 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,12 @@ pip install geopy pip install maidenhead pip install beautifulsoup4 pip install dadjokes +``` +The following is needed for open-meteo use +``` pip install openmeteo_requests pip install retry_requests +pip install numpy ``` To enable emoji in the Debian console, install the fonts `sudo apt-get install fonts-noto-color-emoji` diff --git a/requirements.txt b/requirements.txt index 3f98692..c6b205a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ maidenhead beautifulsoup4 dadjokes openmeteo_requests -retry_requests \ No newline at end of file +retry_requests +numpy \ No newline at end of file From 35df43b72764baec41655709dc772194ba436676 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 9 Aug 2024 23:09:21 -0700 Subject: [PATCH 2/7] bbspost by shortname this is very basic for now --- mesh_bot.py | 16 ++++++++++++---- modules/system.py | 13 +++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 4e9429d..45f9a1d 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -92,16 +92,16 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi elif "wxc" in message.lower() or "wx" in message.lower(): location = get_node_location(message_from_id, deviceID) if use_meteo_wxApi and not "wxc" in message.lower() and not use_metric: - logger.debug(f"System: Returning Open-Meteo API for weather imperial") + logger.debug(f"System: Bot Returning Open-Meteo API for weather imperial") weather = get_wx_meteo(str(location[0]),str(location[1])) elif use_meteo_wxApi: - logger.debug(f"System: Returning Open-Meteo API for weather metric") + logger.debug(f"System: Bot Returning Open-Meteo API for weather metric") weather = get_wx_meteo(str(location[0]),str(location[1]),1) elif not use_meteo_wxApi and "wxc" in message.lower() or use_metric: - logger.debug(f"System: Returning NOAA API for weather metric") + logger.debug(f"System: Bot Returning NOAA API for weather metric") weather = get_weather(str(location[0]),str(location[1]),1) else: - logger.debug(f"System: Returning NOAA API for weather imperial") + logger.debug(f"System: Bot Returning NOAA API for weather imperial") weather = get_weather(str(location[0]),str(location[1])) bot_response = weather elif "joke" in message.lower(): @@ -124,6 +124,14 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi elif "@" in message and not "example:" in message: toNode = message.split("@")[1].split("#")[0] toNode = toNode.rstrip() + # if toNode is a string look for short name and convert to number + if toNode.isalpha(): + toNode = get_num_from_short_name(toNode, deviceID) + if toNode == 0: + bot_response = "Node not found " + message.split("@")[1].split("#")[0] + ", case sensitive!" + return bot_response + else: + logger.debug(f"Bot: bbspost, Node name lookup found: {toNode} for " + message.split("@")[1].split("#")[0]) if "#" in message: body = message.split("#")[1] bot_response = bbs_post_dm(toNode, body, message_from_id) diff --git a/modules/system.py b/modules/system.py index 02f06a9..a6c1b88 100644 --- a/modules/system.py +++ b/modules/system.py @@ -149,6 +149,19 @@ def get_name_from_number(number, type='long', nodeInt=1): name = str(decimal_to_hex(number)) # If name not found, use the ID as string return name return number + +def get_num_from_short_name(short_name, nodeInt=1): + # Get the node number from the short name + logger.debug(f"System: Getting Node Number from Short Name: {short_name} on Device: {nodeInt}") + if nodeInt == 1: + for node in interface1.nodes.values(): + if str(short_name) == node['user']['shortName']: + return node['num'] + if nodeInt == 2: + for node in interface2.nodes.values(): + if str(short_name) == node['user']['shortName']: + return node['num'] + return 0 def get_node_list(nodeInt=1): # Get a list of nodes on the device From f73cd5ec31ef390d554e02060909a51f730c8ca7 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 9 Aug 2024 23:19:30 -0700 Subject: [PATCH 3/7] cleanup --- mesh_bot.py | 4 ++-- modules/system.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 45f9a1d..44291ce 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -128,10 +128,10 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi if toNode.isalpha(): toNode = get_num_from_short_name(toNode, deviceID) if toNode == 0: - bot_response = "Node not found " + message.split("@")[1].split("#")[0] + ", case sensitive!" + bot_response = "Node not found " + message.split("@")[1].split("#")[0] return bot_response else: - logger.debug(f"Bot: bbspost, Node name lookup found: {toNode} for " + message.split("@")[1].split("#")[0]) + logger.debug(f"System: bbspost, name lookup found: {toNode}") if "#" in message: body = message.split("#")[1] bot_response = bbs_post_dm(toNode, body, message_from_id) diff --git a/modules/system.py b/modules/system.py index a6c1b88..29f4592 100644 --- a/modules/system.py +++ b/modules/system.py @@ -151,15 +151,15 @@ def get_name_from_number(number, type='long', nodeInt=1): return number def get_num_from_short_name(short_name, nodeInt=1): - # Get the node number from the short name + # Get the node number from the short name, converting all to lowercase for comparison (good practice?) logger.debug(f"System: Getting Node Number from Short Name: {short_name} on Device: {nodeInt}") if nodeInt == 1: for node in interface1.nodes.values(): - if str(short_name) == node['user']['shortName']: + if str(short_name.lower()) == node['user']['shortName'].lower(): return node['num'] if nodeInt == 2: for node in interface2.nodes.values(): - if str(short_name) == node['user']['shortName']: + if str(short_name.lower()) == node['user']['shortName'].lower(): return node['num'] return 0 From d063fdd81d55f4d4e56b6992e7caeff26ac83887 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 9 Aug 2024 23:21:13 -0700 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47f2d36..82d9e3f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Any messages that are over 160 characters are chunked into 160 message bytes to - `bbshelp` returns the following - `bbslist` list the messages by ID and subject - `bbsread` read a message example use: `bbsread #1` - - `bbspost` post a message to public board or send a DM example use: `bbspost $subject #message, or bbspost @nodeNumber #message` + - `bbspost` post a message to public board or send a DM example use: `bbspost $subject #message, or bbspost @nodeNumber #message or bbspost @nodeShportName #message` - `bbsdelete` delete a message example use: `bbsdelete #4` - Other functions - `whereami` returns the address of location of sender if known From d43e28d723dbc14a341bdc937dc896d6aedf18d9 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 9 Aug 2024 23:21:50 -0700 Subject: [PATCH 5/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82d9e3f..b3b8502 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The feature-rich bot requires the internet for full functionality. These respond Along with network testing, this bot has a lot of other features, like simple mail messaging you can leave for another device, and when that device is seen, it can send the mail as a DM. -The bot is also capable of using dual radio/nodes, so you can monitor two networks at the same time and send messages to nodes using the same `bbspost @nodeNumber #message` function. There is a small message board to fit in the constraints of Meshtastic for posting bulletin messages with `bbspost $subject #message`. +The bot is also capable of using dual radio/nodes, so you can monitor two networks at the same time and send messages to nodes using the same `bbspost @nodeNumber #message` or `bbspost @nodeShportName #message` function. There is a small message board to fit in the constraints of Meshtastic for posting bulletin messages with `bbspost $subject #message`. Store and forward-like message re-play with `messages`, and there is a repeater module for dual radio bots to cross post messages. Messages are also logged locally to disk. From 773ee78fb2aaa4f020f743622e49e2bdcc5e39c2 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 9 Aug 2024 23:22:24 -0700 Subject: [PATCH 6/7] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 44291ce..a655c73 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -136,7 +136,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi body = message.split("#")[1] bot_response = bbs_post_dm(toNode, body, message_from_id) else: - bot_response = "example: bbspost @nodeNumber #message" + bot_response = "example: bbspost @nodeNumber/ShortName #message" elif not "example:" in message: bot_response = "example: bbspost $subject #message, or bbspost @nodeNumber #message" From 29fb8b0b40d824343feef86a52101bfcef81249a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 9 Aug 2024 23:22:57 -0700 Subject: [PATCH 7/7] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index a655c73..a376e36 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -138,7 +138,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi else: bot_response = "example: bbspost @nodeNumber/ShortName #message" elif not "example:" in message: - bot_response = "example: bbspost $subject #message, or bbspost @nodeNumber #message" + bot_response = "example: bbspost $subject #message, or bbspost @node #message" elif "bbsread" in message.lower(): # Check if the user added a message number to the message