diff --git a/app/bot.py b/app/bot.py index 913a5394..414e576c 100644 --- a/app/bot.py +++ b/app/bot.py @@ -3,7 +3,7 @@ Bot execution module for automatic message responses. This module provides functionality for executing user-defined Python code in response to incoming messages. The user's code can process message data -and optionally return a response string. +and optionally return a response string or a list of strings. SECURITY WARNING: This executes arbitrary Python code provided by the user. It should only be enabled on trusted systems where the user understands diff --git a/app/routers/messages.py b/app/routers/messages.py index 4e8ba69b..fe043925 100644 --- a/app/routers/messages.py +++ b/app/routers/messages.py @@ -175,9 +175,15 @@ async def send_channel_message(request: SendChannelMessageRequest) -> Message: logger.info("Sending channel message to %s: %s", db_channel.name, request.text[:50]) + # Capture timestamp BEFORE sending so we can pass the same value to both the radio + # and the database. This ensures the echo's timestamp matches our stored message + # for proper deduplication. + now = int(time.time()) + result = await mc.commands.send_chan_msg( chan=TEMP_RADIO_SLOT, msg=request.text, + timestamp=now, ) if result.type == EventType.ERROR: @@ -186,7 +192,6 @@ async def send_channel_message(request: SendChannelMessageRequest) -> Message: # Store outgoing message with sender prefix (to match echo format) # The radio includes "SenderName: " prefix when broadcasting, so we store it the same way # to enable proper deduplication when the echo comes back - now = int(time.time()) channel_key_upper = request.channel_key.upper() radio_name = mc.self_info.get("name", "") if mc.self_info else "" text_with_sender = f"{radio_name}: {request.text}" if radio_name else request.text