Move logging after plugins because sometimes the room doesn't get notified. Add method for lost connection, used in a future commit

feature/plugins-parameters
Geoff Whittington 2023-05-12 10:47:23 -04:00
rodzic e0f47a8da6
commit 08115e975c
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -33,6 +33,11 @@ def connect_meshtastic():
return meshtastic_client
def on_lost_meshtastic_connection(interface):
logger.error("Lost connection. Reconnecting...")
connect_meshtastic()
# Callback for new messages from Meshtastic
def on_meshtastic_message(packet, loop=None):
from matrix_utils import matrix_relay
@ -70,9 +75,6 @@ def on_meshtastic_message(packet, loop=None):
meshnet_name = relay_config["meshtastic"]["meshnet_name"]
formatted_message = f"[{longname}/{meshnet_name}]: {text}"
logger.info(
f"Relaying Meshtastic message from {longname} to Matrix: {formatted_message}"
)
# Plugin functionality
plugins = load_plugins()
@ -93,6 +95,10 @@ def on_meshtastic_message(packet, loop=None):
if found_matching_plugin:
return
logger.info(
f"Relaying Meshtastic message from {longname} to Matrix: {formatted_message}"
)
for room in matrix_rooms:
if room["meshtastic_channel"] == channel:
asyncio.run_coroutine_threadsafe(