Skip to content

Commit c5be524

Browse files
committed
Added speedtest command for bot owner
1 parent 4c4400e commit c5be524

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

hexbot.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import fortune
1414
import aiopentdb
1515
import time
16+
from speedtest import Speedtest
1617

1718

1819
ytdlopts = {
@@ -465,6 +466,20 @@ async def ping(self, ctx):
465466
ping = (time.monotonic() - before) * 1000
466467
await message.edit(content=f"Pong! \nPing: `{int(ping)}ms`\nLatency: `{int(bot.latency*1000)}ms`")
467468

469+
@commands.command(name='speedtest')
470+
async def speed_test(self, ctx):
471+
"""Speedtest"""
472+
async with ctx.typing():
473+
if await bot.is_owner(ctx.author):
474+
s = Speedtest()
475+
s.download()
476+
s.upload()
477+
s = s.results.dict()
478+
479+
await ctx.send(f"Ping: `{s['ping']}ms`\nDownload: `{round(s['download']/10**6, 3)}Mbits/s`\nUpload: `{round(s['download']/10**6, 3)}Mbits/s`\nServer: `{s['server']['sponsor']} {s['server']['name']} {s['server']['country']}`\nBot info:\n `{s['client']['isp']}({s['client']['ip']})[{s['client']['country']}] {s['client']['isprating']}`")
480+
else:
481+
await ctx.send("Only bot owner is permitted to use this command")
482+
468483
@listusers.before_invoke
469484
@teams.before_invoke
470485
async def ensure_author_voice(self, ctx):

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ PyNaCl==1.3.0
44
async-timeout==3.0.1
55
youtube_dl
66
fortune
7-
aiopentdb
7+
aiopentdb
8+
speedtest-cli

0 commit comments

Comments
 (0)