misc(speedtest): doing some testing

This commit is contained in:
Seaswimmer 2024-05-25 18:08:18 -04:00
parent d557928fee
commit cba25d1f94
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 13 additions and 9 deletions

View file

@ -34,6 +34,16 @@ class Bandwidth(BaseModel):
elapsed: int elapsed: int
latency: "Latency" latency: "Latency"
@property
def mbps(self) -> float:
return self.bandwidth / 1_000_000
class Latency(BaseModel):
iqm: float
low: float
high: float
jitter: float
class Interface(BaseModel): class Interface(BaseModel):
internalIp: str internalIp: str
name: str name: str
@ -47,12 +57,6 @@ class Ping(BaseModel):
low: float low: float
high: float high: float
class Latency(BaseModel):
iqm: float
low: float
high: float
jitter: float
class Server(BaseModel): class Server(BaseModel):
id: int id: int
name: str name: str

View file

@ -62,16 +62,16 @@ class Speedtest(commands.Cog):
await msg.edit(embed=discord.Embed(description=f"An error occurred! {speedtest}", color=discord.Colour.red())) await msg.edit(embed=discord.Embed(description=f"An error occurred! {speedtest}", color=discord.Colour.red()))
return return
embed = discord.Embed(title="Speedtest Results", url=speedtest.result.url, color=await ctx.embed_color()) embed = discord.Embed(title="Speedtest Results", url=speedtest.result.url, color=await ctx.embed_color())
embed.add_field(name="Bandwidth", value=f"{speedtest.download.bandwidth / 1_000_000:.2f} Mbps down, {speedtest.download.bandwidth / 1_000_000:.2f} Mbps up") embed.add_field(name="Bandwidth", value=f"{speedtest.download.mbps:,.2f} Mbps down, {speedtest.upload.mbps:,.2f} Mbps up")
embed.add_field(name="Ping", value=f"Base: {round(speedtest.ping.latency)} ms \nDownload: {round(speedtest.download.latency.iqm)} ms \nUpload: {round(speedtest.upload.latency.iqm)} ms") embed.add_field(name="Ping", value=f"Base: {round(speedtest.ping.latency)} ms \nDownload: {round(speedtest.download.latency.iqm)} ms \nUpload: {round(speedtest.upload.latency.iqm)} ms")
embed.set_image(url=speedtest.result.image) embed.set_image(url=speedtest.result.image)
await msg.edit(embed=embed) await msg.edit(embed=embed)
else: else:
if not isinstance(speedtest, sp): if not isinstance(speedtest, sp):
await msg.edit(content=f"An error occurred! {speedtest}") await msg.edit(content=f"An error occurred! \n`{speedtest}`")
return return
await msg.edit(content=f"**Speedtest Results**\n" await msg.edit(content=f"**Speedtest Results**\n"
f"**Bandwidth**: {speedtest.download.bandwidth / 1_000_000:.2f} Mbps down, {speedtest.download.bandwidth / 1_000_000:.2f} Mbps up\n" f"**Bandwidth**: {speedtest.download.mbps:,.2f} Mbps down, {speedtest.download.mbps:,.2f} Mbps up\n"
f"**Ping**: Base: {round(speedtest.ping.latency)} ms\n" f"**Ping**: Base: {round(speedtest.ping.latency)} ms\n"
f"Download: {round(speedtest.download.latency.iqm)} ms\n" f"Download: {round(speedtest.download.latency.iqm)} ms\n"
f"Upload: {round(speedtest.upload.latency.iqm)} ms\n" f"Upload: {round(speedtest.upload.latency.iqm)} ms\n"