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"