mmrelay 1.1.2__py3-none-any.whl → 1.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mmrelay might be problematic. Click here for more details.

mmrelay/__init__.py CHANGED
@@ -2,16 +2,4 @@
2
2
  Meshtastic Matrix Relay - Bridge between Meshtastic mesh networks and Matrix chat rooms.
3
3
  """
4
4
 
5
- import os
6
- from importlib.metadata import PackageNotFoundError, version
7
-
8
- # First try to get version from environment variable (GitHub tag)
9
- if "GITHUB_REF_NAME" in os.environ:
10
- __version__ = os.environ.get("GITHUB_REF_NAME")
11
- else:
12
- # Fall back to package metadata using importlib.metadata (modern replacement for pkg_resources)
13
- try:
14
- __version__ = version("mmrelay")
15
- except PackageNotFoundError:
16
- # If all else fails, use hardcoded version
17
- __version__ = "1.1.2"
5
+ __version__ = "1.1.3"
mmrelay/main.py CHANGED
@@ -27,6 +27,12 @@ from mmrelay.matrix_utils import logger as matrix_logger
27
27
  from mmrelay.matrix_utils import on_room_member, on_room_message
28
28
  from mmrelay.meshtastic_utils import connect_meshtastic
29
29
  from mmrelay.meshtastic_utils import logger as meshtastic_logger
30
+ from mmrelay.message_queue import (
31
+ DEFAULT_MESSAGE_DELAY,
32
+ get_message_queue,
33
+ start_message_queue,
34
+ stop_message_queue,
35
+ )
30
36
  from mmrelay.plugin_loader import load_plugins
31
37
 
32
38
  # Initialize logger
@@ -51,9 +57,9 @@ def print_banner():
51
57
 
52
58
  async def main(config):
53
59
  """
54
- Run the main asynchronous relay loop, managing connections between Meshtastic and Matrix, event handling, and graceful shutdown.
60
+ Runs the main asynchronous relay loop, managing the lifecycle and coordination between Meshtastic and Matrix clients.
55
61
 
56
- Initializes the database, loads plugins, connects to Meshtastic and Matrix, joins configured Matrix rooms, and registers event callbacks for message and membership events. Periodically updates node names from the Meshtastic network and manages the Matrix sync loop, handling reconnections and shutdown signals. If configured, wipes the message map on both startup and shutdown.
62
+ Initializes the database, loads plugins, starts the message queue, and establishes connections to both Meshtastic and Matrix. Joins configured Matrix rooms, registers event callbacks for message and membership events, and periodically updates node names from the Meshtastic network. Monitors connection health, manages the Matrix sync loop with reconnection and shutdown handling, and ensures graceful shutdown of all components, including optional message map wiping on startup and shutdown if configured.
57
63
  """
58
64
  # Extract Matrix configuration
59
65
  from typing import List
@@ -90,6 +96,12 @@ async def main(config):
90
96
  # Load plugins early
91
97
  load_plugins(passed_config=config)
92
98
 
99
+ # Start message queue with configured message delay
100
+ message_delay = config.get("meshtastic", {}).get(
101
+ "message_delay", DEFAULT_MESSAGE_DELAY
102
+ )
103
+ start_message_queue(message_delay=message_delay)
104
+
93
105
  # Connect to Meshtastic
94
106
  meshtastic_utils.meshtastic_client = connect_meshtastic(passed_config=config)
95
107
 
@@ -132,6 +144,9 @@ async def main(config):
132
144
  # This provides proactive connection detection for all interface types
133
145
  _ = asyncio.create_task(meshtastic_utils.check_connection())
134
146
 
147
+ # Ensure message queue processor is started now that event loop is running
148
+ get_message_queue().ensure_processor_started()
149
+
135
150
  # Start the Matrix client sync loop
136
151
  try:
137
152
  while not shutdown_event.is_set():
@@ -173,6 +188,9 @@ async def main(config):
173
188
  await shutdown()
174
189
  finally:
175
190
  # Cleanup
191
+ matrix_logger.info("Stopping message queue...")
192
+ stop_message_queue()
193
+
176
194
  matrix_logger.info("Closing Matrix client...")
177
195
  await matrix_client.close()
178
196
  if meshtastic_utils.meshtastic_client: