Fix occasional outgoing message dupe glitch due to mismatched send vs. radio timestamps

This commit is contained in:
Jack Kingsman
2026-01-27 12:05:15 -08:00
parent 401c7d3c0e
commit e2b4d7b8fe
2 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -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