kopia lustrzana https://github.com/mate-dev/meshtastic-matrix-relay
Move logging after plugins because sometimes the room doesn't get notified. Add method for lost connection, used in a future commit
rodzic
e0f47a8da6
commit
08115e975c
|
@ -33,6 +33,11 @@ def connect_meshtastic():
|
||||||
return meshtastic_client
|
return meshtastic_client
|
||||||
|
|
||||||
|
|
||||||
|
def on_lost_meshtastic_connection(interface):
|
||||||
|
logger.error("Lost connection. Reconnecting...")
|
||||||
|
connect_meshtastic()
|
||||||
|
|
||||||
|
|
||||||
# Callback for new messages from Meshtastic
|
# Callback for new messages from Meshtastic
|
||||||
def on_meshtastic_message(packet, loop=None):
|
def on_meshtastic_message(packet, loop=None):
|
||||||
from matrix_utils import matrix_relay
|
from matrix_utils import matrix_relay
|
||||||
|
@ -70,9 +75,6 @@ def on_meshtastic_message(packet, loop=None):
|
||||||
meshnet_name = relay_config["meshtastic"]["meshnet_name"]
|
meshnet_name = relay_config["meshtastic"]["meshnet_name"]
|
||||||
|
|
||||||
formatted_message = f"[{longname}/{meshnet_name}]: {text}"
|
formatted_message = f"[{longname}/{meshnet_name}]: {text}"
|
||||||
logger.info(
|
|
||||||
f"Relaying Meshtastic message from {longname} to Matrix: {formatted_message}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Plugin functionality
|
# Plugin functionality
|
||||||
plugins = load_plugins()
|
plugins = load_plugins()
|
||||||
|
@ -93,6 +95,10 @@ def on_meshtastic_message(packet, loop=None):
|
||||||
if found_matching_plugin:
|
if found_matching_plugin:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
f"Relaying Meshtastic message from {longname} to Matrix: {formatted_message}"
|
||||||
|
)
|
||||||
|
|
||||||
for room in matrix_rooms:
|
for room in matrix_rooms:
|
||||||
if room["meshtastic_channel"] == channel:
|
if room["meshtastic_channel"] == channel:
|
||||||
asyncio.run_coroutine_threadsafe(
|
asyncio.run_coroutine_threadsafe(
|
||||||
|
|
Ładowanie…
Reference in New Issue