From a9739c1865f67cf0cef9fd688bb5011f3d0609bb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 1 Jul 2020 16:47:30 +0200 Subject: [PATCH] publish: 5.9.4 --- royalpack/commands/ping.py | 9 +++++++-- royalpack/events/pong.py | 3 ++- royalpack/version.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/royalpack/commands/ping.py b/royalpack/commands/ping.py index a681bc1d..576f6e63 100644 --- a/royalpack/commands/ping.py +++ b/royalpack/commands/ping.py @@ -1,3 +1,4 @@ +import datetime import asyncio from typing import * import royalnet @@ -18,6 +19,7 @@ class PingCommand(rc.Command): tasks = {} + start = datetime.datetime.now() for target in self._targets: tasks[target] = self.loop.create_task(self.interface.call_herald_event(target, "pong")) @@ -27,10 +29,13 @@ class PingCommand(rc.Command): for name, task in tasks.items(): try: - print(task.result()) + d = task.result() except (asyncio.CancelledError, asyncio.InvalidStateError): lines.append(f"🔴 [c]{name}[/c]") else: - lines.append(f"🔵 [c]{name}[/c]") + end = datetime.datetime.fromtimestamp(d["timestamp"]) + delta = end - start + + lines.append(f"🔵 [c]{name}[/c] ({delta.microseconds // 1000} ms)") await data.reply("\n".join(lines)) diff --git a/royalpack/events/pong.py b/royalpack/events/pong.py index d62e6026..b6943e5d 100644 --- a/royalpack/events/pong.py +++ b/royalpack/events/pong.py @@ -1,10 +1,11 @@ from typing import * import royalnet import royalnet.commands as rc +import datetime class PongEvent(rc.Event): name = "pong" async def run(self, **kwargs) -> dict: - return {"status": "connected"} + return {"timestamp": datetime.datetime.now().timestamp()} diff --git a/royalpack/version.py b/royalpack/version.py index d6a72e3e..209315d0 100644 --- a/royalpack/version.py +++ b/royalpack/version.py @@ -1 +1 @@ -semantic = "5.9.3" +semantic = "5.9.4"