def _fileCheck(msg):
url = msg.attachments[0]['url']
allowedExtension = ['.exe', '.zip', '.rar']
if url[-4:] in allowedExtension:
name = os.path.basename(url)
downloadPath = 'tmp\\' + name
async with aiohttp.get(url) as download:
with open(downloadPath, 'wb') as f:
f.write(await download.read())
stats = os.stat(downloadPath)
size = stats.st_size
KBSize = round(size / 1024, 3)
MBSize = round(size / 1024 / 1024, 3)
MD5 = _getHash(downloadPath, hashlib.md5())
SHA1 = _getHash(downloadPath, hashlib.sha1())
SHA256 = _getHash(downloadPath, hashlib.sha256())
SHA512 = _getHash(downloadPath, hashlib.sha512())
msg = f'**Name:** {name}\n'
msg += f'**Size:** {MBSize} MB ({size} Bytes)\n'
msg += f'**MD5:** `{MD5}`\n'
msg += f'**SHA1:** `{SHA1}`\n'
msg += f'**SHA256:** `{SHA256}`\n'
msg += f'**SHA512:** `{SHA512}`\n'
os.remove(downloadPath)
return msg
评论列表
文章目录