🐛 Fix speedtest error
This commit is contained in:
parent
6b2da9212d
commit
4b24523fd9
@ -260,9 +260,11 @@ async def speedtest(context):
|
|||||||
test.download()
|
test.download()
|
||||||
test.upload()
|
test.upload()
|
||||||
test.results.share()
|
test.results.share()
|
||||||
except (ShareResultsConnectFailure, ShareResultsSubmitFailure, RuntimeError) as e:
|
except (ShareResultsSubmitFailure, RuntimeError) as e:
|
||||||
await context.edit(lang('speedtest_ConnectFailure'))
|
await context.edit(lang('speedtest_ConnectFailure'))
|
||||||
return
|
return
|
||||||
|
except ShareResultsConnectFailure:
|
||||||
|
pass
|
||||||
result = test.results.dict()
|
result = test.results.dict()
|
||||||
des = (
|
des = (
|
||||||
f"**Speedtest** \n"
|
f"**Speedtest** \n"
|
||||||
@ -275,24 +277,27 @@ async def speedtest(context):
|
|||||||
f"Timestamp: `{result['timestamp']}`"
|
f"Timestamp: `{result['timestamp']}`"
|
||||||
)
|
)
|
||||||
# 开始处理图片
|
# 开始处理图片
|
||||||
data = get(result['share']).content
|
if result['share']:
|
||||||
with open('speedtest.png', mode='wb') as f:
|
data = get(result['share']).content
|
||||||
f.write(data)
|
with open('speedtest.png', mode='wb') as f:
|
||||||
try:
|
f.write(data)
|
||||||
img = Image.open('speedtest.png')
|
try:
|
||||||
c = img.crop((17, 11, 727, 389))
|
img = Image.open('speedtest.png')
|
||||||
c.save('speedtest.png')
|
c = img.crop((17, 11, 727, 389))
|
||||||
except:
|
c.save('speedtest.png')
|
||||||
pass
|
except:
|
||||||
try:
|
pass
|
||||||
await context.client.send_file(context.chat_id, 'speedtest.png', caption=des)
|
try:
|
||||||
except:
|
await context.client.send_file(context.chat_id, 'speedtest.png', caption=des)
|
||||||
return
|
except:
|
||||||
try:
|
return
|
||||||
remove('speedtest.png')
|
try:
|
||||||
except:
|
remove('speedtest.png')
|
||||||
pass
|
except:
|
||||||
await context.delete()
|
pass
|
||||||
|
await context.delete()
|
||||||
|
else:
|
||||||
|
await context.edit(des)
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=False, outgoing=True, command=alias_command("connection"),
|
@listener(is_plugin=False, outgoing=True, command=alias_command("connection"),
|
||||||
|
Loading…
Reference in New Issue
Block a user