🗺️ howfar

This commit is contained in:
SpudGunMan
2025-09-09 12:42:03 -07:00
parent ff9b76c966
commit 5703cfb381
3 changed files with 29 additions and 6 deletions
+1
View File
@@ -137,6 +137,7 @@ git clone https://github.com/spudgunman/meshing-around
| `readnews` | returns the contents of a file (news.txt, by default) via the chunker on air | ✅ |
| `satpass` | returns the pass info from API for defined NORAD ID in config or Example: `satpass 25544,33591`| |
| `wiki:` | Searches Wikipedia and returns the first few sentences of the first result if a match. Example: `wiki: lora radio` |
| `howfar` | returns the distance you have traveled since your last HowFar. `howfar reset` to start over | ✅ |
### CheckList
| Command | Description | |
+18 -3
View File
@@ -61,7 +61,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n
"hangman": lambda: handleHangman(message, message_from_id, deviceID),
"hfcond": hf_band_conditions,
"history": lambda: handle_history(message, message_from_id, deviceID, isDM),
"howfar": lambda: handle_howfar(message_from_id, deviceID, channel_number),
"howfar": lambda: handle_howfar(message, message_from_id, deviceID, isDM),
"joke": lambda: tell_joke(message_from_id),
"lemonstand": lambda: handleLemonade(message, message_from_id, deviceID),
"lheard": lambda: handle_lheard(message, message_from_id, deviceID, isDM),
@@ -312,14 +312,29 @@ def handle_wxalert(message_from_id, deviceID, message):
weatherAlert = weatherAlert[0]
return weatherAlert
def handle_howfar(message_from_id, deviceID, channel_number):
def handle_howfar(message, message_from_id, deviceID, isDM):
msg = ''
location = get_node_location(message_from_id, deviceID)
lat = location[0]
lon = location[1]
# if ? in message
if "?" in message.lower():
return "command returns the distance you have traveled since your last HowFar-command. Add 'reset' to reset your starting point."
# if no GPS location return
if lat == latitudeValue and lon == longitudeValue:
logger.debug(f"System: HowFar: No GPS location for {message_from_id}")
return "No GPS location available"
msg = distance(lat,lon,message_from_id)
if "reset" in message.lower():
msg = distance(lat,lon,message_from_id, reset=True)
else:
msg = distance(lat,lon,message_from_id)
# if not a DM add the username to the beginning of msg
if not useDMForResponse and not isDM:
msg = "@" + get_name_from_number(message_from_id, 'short', deviceID) + " " + msg
return msg
def handle_wiki(message, isDM):
+10 -3
View File
@@ -815,7 +815,7 @@ def checkUSGSEarthQuake(lat=0, lon=0):
return f"{quake_count} quakes in last {history} days within {radius}km of you largest was {largest_mag}. {description_text}"
howfarDB = {}
def distance(lat=0,lon=0,nodeID=0):
def distance(lat=0,lon=0,nodeID=0, reset=False):
# part of the howfar function, calculates the distance between two lat/lon points
msg = ""
if lat == 0 and lon == 0:
@@ -823,14 +823,21 @@ def distance(lat=0,lon=0,nodeID=0):
if nodeID == 0:
return "No NodeID provided"
if reset:
if nodeID in howfarDB:
del howfarDB[nodeID]
if nodeID not in howfarDB:
#register first point NodeID, lat, lon, time, point
howfarDB[nodeID] = [{'lat': lat, 'lon': lon, 'time': datetime.now()}]
return "Starting Point Set"
if reset:
return "Tracking reset, new starting point registered🗺️"
else:
return "Starting point registered🗺️"
else:
#de-dupe points if same as last point
if howfarDB[nodeID][-1]['lat'] == lat and howfarDB[nodeID][-1]['lon'] == lon:
return "No movement detected"
return "📍No movement detected yet"
# calculate distance from last point in howfarDB
last_point = howfarDB[nodeID][-1]
lat1 = math.radians(last_point['lat'])