kopia lustrzana https://github.com/mate-dev/meshtastic-matrix-relay
Merge pull request #3 from CezaryPuchowski/Markdown-in-some-plugins
nodes_plugin response in mdmain
commit
2851615fdc
|
@ -47,27 +47,30 @@ $shortname $longname / $devicemodel / $battery $voltage / $snr / $lastseen
|
||||||
|
|
||||||
meshtastic_client = connect_meshtastic()
|
meshtastic_client = connect_meshtastic()
|
||||||
|
|
||||||
response = f"Nodes: {len(meshtastic_client.nodes)}\n"
|
response = f">**Nodes: {len(meshtastic_client.nodes)}**\n\n"
|
||||||
|
|
||||||
for node, info in meshtastic_client.nodes.items():
|
for node, info in meshtastic_client.nodes.items():
|
||||||
|
snr = ""
|
||||||
if "snr" in info:
|
if "snr" in info:
|
||||||
snr = f"{info['snr']} dB"
|
if info['snr'] is not None:
|
||||||
else:
|
snr = f"{info['snr']} dB "
|
||||||
snr = ""
|
|
||||||
|
|
||||||
last_heard = None
|
last_heard = None
|
||||||
if "lastHeard" in info:
|
if "lastHeard" in info:
|
||||||
last_heard = get_relative_time(info["lastHeard"])
|
last_heard = get_relative_time(info["lastHeard"])
|
||||||
|
|
||||||
voltage = "?V"
|
voltage = ""
|
||||||
battery = "?%"
|
battery = ""
|
||||||
if "deviceMetrics" in info:
|
if "deviceMetrics" in info:
|
||||||
if "voltage" in info["deviceMetrics"]:
|
if "voltage" in info["deviceMetrics"]:
|
||||||
voltage = f"{info['deviceMetrics']['voltage']}V"
|
voltage = f"{info['deviceMetrics']['voltage']}V "
|
||||||
if "batteryLevel" in info["deviceMetrics"]:
|
if "batteryLevel" in info["deviceMetrics"]:
|
||||||
battery = f"{info['deviceMetrics']['batteryLevel']}%"
|
battery = f"{info['deviceMetrics']['batteryLevel']}% "
|
||||||
|
|
||||||
response += f"{info['user']['shortName']} {info['user']['longName']} / {info['user']['hwModel']} / {battery} {voltage} / {snr} / {last_heard}\n"
|
response += f"><hr/>\n\n"\
|
||||||
|
f">**{info['user']['shortName']}** {info['user']['longName']}\n\n"\
|
||||||
|
f">{info['user']['hwModel']} {battery}{voltage}\n\n"\
|
||||||
|
f">{snr}{last_heard}\n\n"
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ $shortname $longname / $devicemodel / $battery $voltage / $snr / $lastseen
|
||||||
return False
|
return False
|
||||||
|
|
||||||
response = await self.send_matrix_message(
|
response = await self.send_matrix_message(
|
||||||
room_id=room.room_id, message=self.generate_response(), formatted=False
|
room_id=room.room_id, message=self.generate_response(), formatted=True
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -3,7 +3,7 @@ Pillow==9.5.0
|
||||||
py-staticmaps==0.4.0
|
py-staticmaps==0.4.0
|
||||||
matrix-nio==0.20.2
|
matrix-nio==0.20.2
|
||||||
matplotlib==3.7.1
|
matplotlib==3.7.1
|
||||||
requests==2.30.0
|
requests==2.31.0
|
||||||
markdown==3.4.3
|
markdown==3.4.3
|
||||||
haversine==2.8.0
|
haversine==2.8.0
|
||||||
schedule==1.2.0
|
schedule==1.2.0
|
||||||
|
|
Ładowanie…
Reference in New Issue