From cf783ebce515a52572ccd992deb911612b2a8743 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 17 Jul 2022 19:06:05 +0800 Subject: [PATCH] =?UTF-8?q?speed=5Ftest=20=E4=BF=AE=E5=A4=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 2 +- speed_test/main.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/list.json b/list.json index c463da6..3b395f5 100644 --- a/list.json +++ b/list.json @@ -342,7 +342,7 @@ }, { "name": "speed_test", - "version": "1.002", + "version": "1.003", "section": "chat", "maintainer": "xtaodada", "size": "3.02 kb", diff --git a/speed_test/main.py b/speed_test/main.py index 5e7fae2..ab16fc1 100644 --- a/speed_test/main.py +++ b/speed_test/main.py @@ -34,11 +34,14 @@ def unit_convert(byte): async def run_speedtest(message: Message): test = Speedtest() - server = [int(message.arguments)] if len(message.parameter) == 1 else [] + server = int(message.arguments) if len(message.parameter) == 1 else None if server: - test.get_servers(servers=server) - else: - test.get_best_server(servers=test.servers) + servers = test.get_closest_servers() + for i in servers: + if i["id"] == str(server): + test.servers = i + break + test.get_best_server(servers=test.servers) test.download() test.upload() with contextlib.suppress(ShareResultsConnectFailure):