ping: always show round-trip time instead of only when >500ms
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -137,11 +137,9 @@ async def cmd_help(client: AsyncClient, room_id: str, sender: str, args: str):
|
|||||||
@command("ping", "Check bot latency")
|
@command("ping", "Check bot latency")
|
||||||
async def cmd_ping(client: AsyncClient, room_id: str, sender: str, args: str):
|
async def cmd_ping(client: AsyncClient, room_id: str, sender: str, args: str):
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
_ = await send_text(client, room_id, "Pong!")
|
await send_text(client, room_id, "Pong!")
|
||||||
elapsed = (time.monotonic() - start) * 1000
|
elapsed = (time.monotonic() - start) * 1000
|
||||||
# Edit isn't straightforward in Matrix, so just send a follow-up if slow
|
await send_text(client, room_id, f"round-trip: {elapsed:.0f}ms")
|
||||||
if elapsed > 500:
|
|
||||||
await send_text(client, room_id, f"(round-trip: {elapsed:.0f}ms)")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user