Files
forust fb43306571
lint / prettier (push) Successful in 8s
lint / ruff (push) Successful in 5s
lint / yamllint (push) Successful in 7s
lint / hadolint (push) Failing after 4s
validate / yaml (push) Successful in 5s
validate / k8s (push) Successful in 5s
Fix all lint issues: Dockerfiles (DL3015/DL3013/DL4006) + Ruff (173→0 errors)
Dockerfile fixes:
- edu_master/phpsessid-bot: add --no-install-recommends, pin pip versions
- edu_master/webinar-checker: pin pip versions with --no-cache-dir
- userbot: add SHELL with pipefail for pipe operations

Ruff fixes (173 → 0):
- W293/W291/W292: whitespace clean via ruff format
- N806: camelCase → snake_case (anilist, safone, hearts, flux, etc.)
- ARG001/ARG002: prefix unused params with _
- SIM115: use context managers for file I/O
- SIM117: combine nested with statements
- S608: noqa on SQL f-strings (module name is validated)
- E402/N812/N817: import fixes
- B023: pass loop variable as argument
- I001: auto-sorted imports
- syntax: fixed = vs == in dtek_notif/main.py
2026-06-21 22:01:51 +02:00

138 lines
5.1 KiB
Python

# Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >.
#
# This file is part of < https://github.com/DevsExpo/FridayUserBot > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/DevsExpo/blob/master/LICENSE >
#
# All rights reserved.
import os
import time
import requests
from pyrogram import Client, enums, filters
from pyrogram.types import Message
from utils.config import vt_key as vak
from utils.misc import modules_help, prefix
from utils.scripts import edit_or_reply, format_exc, progress
@Client.on_message(filters.command('vt', prefix) & filters.me)
async def scan_my_file(_, message: Message):
ms_ = await edit_or_reply(message, '`Please Wait! Scanning This File`')
if not message.reply_to_message:
return await ms_.edit(
'`Please Reply To File To Scan For Viruses`',
parse_mode=enums.ParseMode.MARKDOWN,
)
if not message.reply_to_message.document:
return await ms_.edit(
'`Please Reply To File To Scan For Viruses`',
parse_mode=enums.ParseMode.MARKDOWN,
)
if vak is None:
return await ms_.edit(
'`You Need To Set VIRUSTOTAL_API_KEY For Functing Of This Plugin.`',
parse_mode=enums.ParseMode.MARKDOWN,
)
if int(message.reply_to_message.document.file_size) > 32000000:
return await ms_.edit(
f'**File Too Large, Use `{prefix}vtl` instead**',
parse_mode=enums.ParseMode.MARKDOWN,
)
c_time = time.time()
downloaded_file_name = await message.reply_to_message.download(
progress=progress,
progress_args=(ms_, c_time, '`Downloading This File!`'),
)
url = 'https://www.virustotal.com/vtapi/v2/file/scan'
params = {'apikey': vak}
with open(downloaded_file_name, 'rb') as f:
files = {'file': (downloaded_file_name, f)}
response = requests.post(url, files=files, params=params, timeout=10)
try:
r_json = response.json()
md5 = r_json['md5']
except Exception as e:
return await ms_.edit(format_exc(e))
await ms_.edit(
f'<b><u>Scanned {message.reply_to_message.document.file_name}</b></u>. <b>You Can Visit :</b> <a href="https://www.virustotal.com/gui/file/{md5}">Here</a> <b>In 5-10 Min To See File Report</b>'
)
if os.path.exists(downloaded_file_name):
os.remove(downloaded_file_name)
@Client.on_message(filters.command('vtl', prefix) & filters.me)
async def scan_my_large_file(_, message: Message):
ms_ = await edit_or_reply(message, '`Please Wait! Scanning This File`')
if not message.reply_to_message:
return await ms_.edit(
'`Please Reply To File To Scan For Viruses`',
parse_mode=enums.ParseMode.MARKDOWN,
)
if not message.reply_to_message.document:
return await ms_.edit(
'`Please Reply To File To Scan For Viruses`',
parse_mode=enums.ParseMode.MARKDOWN,
)
if vak is None:
return await ms_.edit(
'`You Need To Set VIRUSTOTAL_API_KEY For Functing Of This Plugin.`',
parse_mode=enums.ParseMode.MARKDOWN,
)
if int(message.reply_to_message.document.file_size) > 650000000:
return await ms_.edit(
'**File Too Large, exceeded Max capacity of 650MB**',
parse_mode=enums.ParseMode.MARKDOWN,
)
c_time = time.time()
downloaded_file_name = await message.reply_to_message.download(
progress=progress,
progress_args=(ms_, c_time, '`Downloading This File!`'),
)
url1 = 'https://www.virustotal.com/api/v3/files/upload_url'
headers = {'accept': 'application/json', 'x-apikey': vak}
rponse = requests.get(url1, headers=headers, timeout=10)
try:
r_json = rponse.json()
upl_data = r_json['data']
except Exception as e:
return await ms_.edit(format_exc(e))
url = upl_data
with open(downloaded_file_name, 'rb') as f:
files = {'file': (downloaded_file_name, f)}
headers = {'accept': 'application/json', 'x-apikey': vak}
response = requests.post(url, files=files, headers=headers, timeout=10)
r_json = response.json()
analysis_url = r_json['data']['links']['self']
url = analysis_url
headers = {'accept': 'application/json', 'x-apikey': vak}
response_result = requests.get(url, headers=headers, timeout=10)
try:
r_json = response_result.json()
md5 = r_json['meta']['file_info']['md5']
except Exception as e:
return await ms_.edit(format_exc(e))
await ms_.edit(
f'<b><u>Scanned {message.reply_to_message.document.file_name}</b></u>. <b>You Can Visit :</b> <a href="https://www.virustotal.com/gui/file/{md5}">Here</a> <b>In 5-10 Min To See File Report</b>'
)
if os.path.exists(downloaded_file_name):
os.remove(downloaded_file_name)
modules_help['virustotal'] = {
'vt [reply to file]*': 'Scan for viruses on Virus Total (for lower file size <32MB)',
'vtl [reply to file]*': 'Scan for viruses on Virus Total (for lower file size >=32MB)',
}