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
This commit is contained in:
2026-06-21 22:01:51 +02:00
parent 4355f451d4
commit 8a1da13383
31 changed files with 163 additions and 145 deletions
+6 -5
View File
@@ -10,15 +10,16 @@ from PIL import Image, ImageDraw, ImageFont
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
from utils.scripts import edit_or_reply
from utils.scripts import reply_check as ReplyCheck
from utils.scripts import edit_or_reply, reply_check
async def amongus_gen(text: str, clr: int) -> str:
url = 'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/Amongus/'
font = ImageFont.truetype(
BytesIO(
requests.get('https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf', timeout=10).content
requests.get(
'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf', timeout=10
).content
),
60,
)
@@ -97,7 +98,7 @@ async def amongus_cmd(client: Client, message: Message):
await client.send_sticker(
message.chat.id,
imposter_file,
reply_to_message_id=ReplyCheck(message),
reply_to_message_id=reply_check(message),
)
@@ -119,7 +120,7 @@ async def imposter_cmd(client: Client, message: Message):
await client.send_photo(
message.chat.id,
imposter_file,
reply_to_message_id=ReplyCheck(message),
reply_to_message_id=reply_check(message),
)
+20 -20
View File
@@ -43,22 +43,22 @@ async def anime_search(client: Client, message: Message):
result = response.json()
averageScore = result['averageScore']
average_score = result['average_score']
try:
coverImage_url = result['imageUrl']
coverImage = requests.get(url=coverImage_url, timeout=10).content
cover_image_url = result['imageUrl']
cover_image = requests.get(url=cover_image_url, timeout=10).content
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
await f.write(coverImage)
await f.write(cover_image)
except Exception:
coverImage = None
cover_image = None
title = result['title']['english']
trailer = result['trailer']['id']
description = result['description']
episodes = result['episodes']
genres = ', '.join(result['genres'])
isAdult = result['isAdult']
is_adult = result['is_adult']
status = result['status']
studios = ', '.join(result['studios'])
@@ -68,7 +68,7 @@ async def anime_search(client: Client, message: Message):
[
InputMediaPhoto(
'coverImage.jpg',
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
)
],
)
@@ -81,7 +81,7 @@ async def anime_search(client: Client, message: Message):
[
InputMediaPhoto(
'coverImage.jpg',
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
)
],
)
@@ -109,22 +109,22 @@ async def manga_search(client: Client, message: Message):
result = response.json()
averageScore = result['averageScore']
average_score = result['average_score']
try:
coverImage_url = result['imageUrl']
coverImage = requests.get(url=coverImage_url, timeout=10).content
cover_image_url = result['imageUrl']
cover_image = requests.get(url=cover_image_url, timeout=10).content
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
await f.write(coverImage)
await f.write(cover_image)
except Exception:
coverImage = None
cover_image = None
title = result['title']['english']
trailer = result['trailer']['id']
description = result['description']
chapters = result['chapters']
genres = ', '.join(result['genres'])
isAdult = result['isAdult']
is_adult = result['is_adult']
status = result['status']
studios = ', '.join(result['studios'])
@@ -134,7 +134,7 @@ async def manga_search(client: Client, message: Message):
[
InputMediaPhoto(
'coverImage.jpg',
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
)
],
)
@@ -147,7 +147,7 @@ async def manga_search(client: Client, message: Message):
[
InputMediaPhoto(
'coverImage.jpg',
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
)
],
)
@@ -176,13 +176,13 @@ async def character(client: Client, message: Message):
result = response.json()
try:
coverImage_url = result['image']['large']
coverImage = requests.get(url=coverImage_url, timeout=10).content
cover_image_url = result['image']['large']
cover_image = requests.get(url=cover_image_url, timeout=10).content
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
await f.write(coverImage)
await f.write(cover_image)
except Exception:
coverImage = None
cover_image = None
age = result['age']
description = result['description']
+1 -1
View File
@@ -49,7 +49,7 @@ async def random():
@Client.on_message(filters.command(['arnd', 'arandom'], prefix) & filters.me)
async def anime_handler(client: Client, message: Message):
async def anime_handler(_client: Client, message: Message):
try:
await message.edit('<b>Searching art</b>', parse_mode=enums.ParseMode.HTML)
ra = await random()
+1 -1
View File
@@ -11,7 +11,7 @@ def id_generator() -> str:
@Client.on_message(filters.command(['bbox', 'blackbox'], prefix) & filters.me)
async def blackbox(client, message):
async def blackbox(_client, message):
m = message
msg = await m.edit_text('🔍')
+1 -1
View File
@@ -5,7 +5,7 @@ from utils.scripts import import_library
cohere = import_library('cohere')
import cohere # noqa: F811
import cohere # noqa: F811, E402
co = cohere.Client(cohere_key)
+3 -1
View File
@@ -15,7 +15,9 @@ from PIL import Image, ImageDraw, ImageFont # noqa: E402
@Client.on_message(filters.command(['dem'], prefix) & filters.me)
async def demotivator(client: Client, message: Message):
await message.edit('<code>Process of demotivation...</code>', parse_mode=enums.ParseMode.HTML)
font = requests.get('https://github.com/The-MoonTg-project/files/blob/main/Times%20New%20Roman.ttf?raw=true', timeout=10)
font = requests.get(
'https://github.com/The-MoonTg-project/files/blob/main/Times%20New%20Roman.ttf?raw=true', timeout=10
)
f = font.content
template_dem = requests.get('https://raw.githubusercontent.com/files/main/demotivator.png', timeout=10)
if message.reply_to_message:
+1 -1
View File
@@ -11,7 +11,7 @@ from lottie.importers import importers # noqa: E402
@Client.on_message(filters.command('destroy', prefix) & filters.me)
async def destroy_sticker(client: Client, message: Message):
async def destroy_sticker(_client: Client, message: Message):
"""Destroy animated stickers by modifying their animation properties"""
try:
reply = message.reply_to_message
+3 -3
View File
@@ -30,11 +30,11 @@ def subprocess_run(cmd):
executable='bash',
)
talk = subproc.communicate()
exitCode = subproc.returncode
if exitCode != 0:
exit_code = subproc.returncode
if exit_code != 0:
reply += (
'```An error was detected while running the subprocess:\n'
f'exit code: {exitCode}\n'
f'exit code: {exit_code}\n'
f'stdout: {talk[0]}\n'
f'stderr: {talk[1]}```'
)
+1 -1
View File
@@ -4,7 +4,7 @@ from utils.misc import prefix
@Client.on_message(filters.command('duck', prefix) & filters.me)
async def duckgo(client: Client, message: Message):
async def duckgo(_client: Client, message: Message):
input_str = ' '.join(message.command[1:])
sample_url = 'https://duckduckgo.com/?q={}'.format(input_str.replace(' ', '+'))
if sample_url:
+1 -1
View File
@@ -29,7 +29,7 @@ from utils.misc import modules_help, prefix
@Client.on_message(filters.command('example_edit', prefix) & filters.me)
async def example_edit(client: Client, message: Message):
async def example_edit(_client: Client, message: Message):
try:
await message.edit('<code>This is an example module</code>')
except Exception as e:
+1 -1
View File
@@ -85,7 +85,7 @@ REPLACEMENT_MAP = {
@Client.on_message(filters.command('flip', prefix) & filters.me)
async def flip(client: Client, message: Message):
async def flip(_client: Client, message: Message):
text = ' '.join(message.command[1:])
final_str = ''
for char in text:
+3 -3
View File
@@ -9,9 +9,9 @@ from utils.scripts import format_exc, progress
def schellwithflux(args):
API_URL = 'https://randydev-ryuzaki-api.hf.space/api/v1/akeno/fluxai'
api_url = 'https://randydev-ryuzaki-api.hf.space/api/v1/akeno/fluxai'
payload = {'user_id': 1191668125, 'args': args} # Please don't edit here
response = requests.post(API_URL, json=payload, timeout=10)
response = requests.post(api_url, json=payload, timeout=10)
if response.status_code != 200:
print(f'Error status {response.status_code}')
return None
@@ -19,7 +19,7 @@ def schellwithflux(args):
@Client.on_message(filters.command('fluxai', prefix) & filters.me)
async def imgfluxai_(client: Client, message: Message):
async def imgfluxai_(_client: Client, message: Message):
question = message.text.split(' ', 1)[1] if len(message.command) > 1 else None
if not question:
return await message.reply_text('Please provide a question for Flux.')
+5 -5
View File
@@ -37,20 +37,20 @@ async def _wrap_edit(message: Message, text: str):
async def phase1(message: Message):
"""Big scroll"""
BIG_SCROLL = '🧡💛💚💙💜🖤🤎'
big_scroll = '🧡💛💚💙💜🖤🤎'
await _wrap_edit(message, joined_heart)
for heart in BIG_SCROLL:
for heart in big_scroll:
await _wrap_edit(message, joined_heart.replace(R, heart))
await asyncio.sleep(SLEEP)
async def phase2(message: Message):
"""Per-heart randomiser"""
ALL = ['❤️'] + list('🧡💛💚💙💜🤎🖤') # don't include white heart
all_hearts = ['❤️'] + list('🧡💛💚💙💜🤎🖤') # don't include white heart
format_heart = joined_heart.replace(R, '{}')
for _ in range(5):
heart = format_heart.format(*random.choices(ALL, k=heartlet_len)) # noqa: S311
heart = format_heart.format(*random.choices(all_hearts, k=heartlet_len)) # noqa: S311
await _wrap_edit(message, heart)
await asyncio.sleep(SLEEP)
@@ -75,7 +75,7 @@ async def phase4(message: Message):
@Client.on_message(filters.command('hearts', prefix) & filters.me)
async def hearts(client: Client, message: Message):
async def hearts(_client: Client, message: Message):
await phase1(message)
await phase2(message)
await phase3(message)
+16 -10
View File
@@ -85,8 +85,8 @@ async def loadmod(_, message: Message):
module_name = url.lower()
try:
f = requests.get(
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt'
, timeout=10).text
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt', timeout=10
).text
except Exception:
return await message.edit('Failed to fetch custom modules list')
modules_dict = {line.split('/')[-1].split()[0]: line.strip() for line in f.splitlines()}
@@ -97,8 +97,9 @@ async def loadmod(_, message: Message):
return
else:
modules_hashes = requests.get(
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/modules_hashes.txt'
, timeout=10).text
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/modules_hashes.txt',
timeout=10,
).text
resp = requests.get(url, timeout=10)
if not resp.ok:
@@ -136,8 +137,8 @@ async def loadmod(_, message: Message):
content = f.read()
modules_hashes = requests.get(
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/modules_hashes.txt'
, timeout=10).text
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/modules_hashes.txt', timeout=10
).text
if hashlib.sha256(content).hexdigest() not in modules_hashes:
os.remove(file_name)
@@ -214,7 +215,9 @@ async def load_all_mods(_, message: Message):
os.mkdir(f'{BASE_PATH}/modules/custom_modules')
try:
f = requests.get('https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt', timeout=10).text
f = requests.get(
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt', timeout=10
).text
except Exception:
return await message.edit('Failed to fetch custom modules list')
modules_list = f.splitlines()
@@ -281,14 +284,17 @@ async def updateallmods(_, message: Message):
if not module_name.endswith('.py'):
continue
try:
f = requests.get('https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt', timeout=10).text
f = requests.get(
'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt', timeout=10
).text
except Exception:
return await message.edit('Failed to fetch custom modules list')
modules_dict = {line.split('/')[-1].split()[0]: line.strip() for line in f.splitlines()}
if module_name in modules_dict:
resp = requests.get(
f'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/{modules_dict[module_name]}.py'
, timeout=10)
f'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/{modules_dict[module_name]}.py',
timeout=10,
)
if not resp.ok:
modules_installed.remove(module_name)
continue
+13 -13
View File
@@ -140,20 +140,20 @@ async def autofwd_main(client: Client, message: Message):
target_chats = db.get('custom.autofwd', 'chatto')
if source_chats is not None and chat_id in source_chats and target_chats is not None:
for chat in target_chats:
for chat in target_chats:
try:
await message.copy(chat)
except Exception as e:
try:
await message.copy(chat)
except Exception as e:
try:
await client.send_message(
'me',
f'Auto Forwarding Failed for Chat with id: <code>{chat_id}</code> to <code>{chat}</code>\n\n{e}',
)
except MessageTooLong:
await client.send_message(
'me',
f'Auto Forwarding Failed for Chat with id: <code>{chat_id}</code> to <code>{chat}</code>, Please check logs!',
)
await client.send_message(
'me',
f'Auto Forwarding Failed for Chat with id: <code>{chat_id}</code> to <code>{chat}</code>\n\n{e}',
)
except MessageTooLong:
await client.send_message(
'me',
f'Auto Forwarding Failed for Chat with id: <code>{chat_id}</code> to <code>{chat}</code>, Please check logs!',
)
modules_help['autofwd'] = {
+14 -14
View File
@@ -63,7 +63,7 @@ async def backup(client: Client, message: Message):
@Client.on_message(filters.command(['restore', 'res'], prefix) & filters.me)
async def restore(client: Client, message: Message):
async def restore(_client: Client, message: Message):
"""
Restore the database
"""
@@ -98,7 +98,7 @@ async def restore(client: Client, message: Message):
@Client.on_message(filters.command(['backupmods', 'bms'], prefix) & filters.me)
async def backupmods(client: Client, message: Message):
async def backupmods(_client: Client, message: Message):
"""
Backup the modules
"""
@@ -112,8 +112,8 @@ async def backupmods(client: Client, message: Message):
for mod in modules_help:
if os.path.isfile(f'modules/custom_modules/{mod}.py'):
f = open(f'backups/{mod}.py', 'wb')
f.write(open(f'modules/custom_modules/{mod}.py', 'rb').read())
with open(f'backups/{mod}.py', 'wb') as f, open(f'modules/custom_modules/{mod}.py', 'rb') as src:
f.write(src.read())
await message.edit(
text='<b>All modules backed up to:</b> <code>backups/</code> folder',
parse_mode=enums.ParseMode.HTML,
@@ -123,7 +123,7 @@ async def backupmods(client: Client, message: Message):
@Client.on_message(filters.command(['backupmod', 'bm'], prefix) & filters.me)
async def backupmod(client: Client, message: Message):
async def backupmod(_client: Client, message: Message):
"""
Backup the module
"""
@@ -142,8 +142,8 @@ async def backupmod(client: Client, message: Message):
await message.edit('<b>Backing up module...</b>', parse_mode=enums.ParseMode.HTML)
if os.path.isfile(f'modules/custom_modules/{mod}.py'):
f = open(f'backups/{mod}.py', 'wb')
f.write(open(f'modules/custom_modules/{mod}.py', 'rb').read())
with open(f'backups/{mod}.py', 'wb') as f, open(f'modules/custom_modules/{mod}.py', 'rb') as src:
f.write(src.read())
else:
return await message.edit(
f'<b>Module <code>{mod}</code> not found.</b>',
@@ -159,7 +159,7 @@ async def backupmod(client: Client, message: Message):
@Client.on_message(filters.command(['restoremod', 'resmod'], prefix) & filters.me)
async def restoremod(client: Client, message: Message):
async def restoremod(_client: Client, message: Message):
"""
Restore the module
"""
@@ -178,11 +178,11 @@ async def restoremod(client: Client, message: Message):
await message.edit('<b>Restoring module...</b>', parse_mode=enums.ParseMode.HTML)
if os.path.isfile(f'backups/{mod}.py'):
f = open(f'modules/custom_modules/{mod}.py', 'wb')
f.write(open(f'backups/{mod}.py', 'rb').read())
with open(f'modules/custom_modules/{mod}.py', 'wb') as f, open(f'backups/{mod}.py', 'rb') as src:
f.write(src.read())
else:
return await message.edit(
f'<b>Module <code>{mod}</code> not found.</b>',
text='<b>Backup file <code>{mod}</code> not found</b>',
parse_mode=enums.ParseMode.HTML,
)
await message.edit(
@@ -195,7 +195,7 @@ async def restoremod(client: Client, message: Message):
@Client.on_message(filters.command(['restoremods', 'resmods'], prefix) & filters.me)
async def restoremods(client: Client, message: Message):
async def restoremods(_client: Client, message: Message):
"""
Restore the modules
"""
@@ -209,8 +209,8 @@ async def restoremods(client: Client, message: Message):
if mod.endswith('.py'):
if os.path.isfile(f'modules/{mod}'):
continue
f = open(f'modules/custom_modules/{mod}', 'wb')
f.write(open(f'backups/{mod}', 'rb').read())
with open(f'modules/custom_modules/{mod}', 'wb') as f, open(f'backups/{mod}', 'rb') as src:
f.write(src.read())
await message.edit(
text='<b>All modules restored from:</b> <code>backups/</code> folder',
parse_mode=enums.ParseMode.HTML,
+1 -1
View File
@@ -41,7 +41,7 @@ def format_time_12hr(time_str: str) -> str:
@Client.on_message(filters.command('prayer', prefix) & filters.me)
async def namaz_times(client: Client, message: Message):
async def namaz_times(_client: Client, message: Message):
if message.reply_to_message:
city_name = message.reply_to_message.text
country_name = DEFAULT_COUNTRY # Default to Pakistan if no country is provided
+21 -21
View File
@@ -166,17 +166,17 @@ async def app(client: Client, message: Message):
result = response.json()
try:
coverImage_url = result['results'][0]['icon']
coverImage = requests.get(url=coverImage_url, timeout=10).content
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
await f.write(coverImage)
cover_image_url = result['results'][0]['icon']
cover_image = requests.get(url=cover_image_url, timeout=10).content
async with aiofiles.open('cover_image.jpg', mode='wb') as f:
await f.write(cover_image)
except Exception:
coverImage = None
cover_image = None
description = result['results'][0]['description']
developer = result['results'][0]['developer']
IsFree = result['results'][0]['free']
is_free = result['results'][0]['free']
genre = result['results'][0]['genre']
package_name = result['results'][0]['id']
title = result['results'][0]['title']
@@ -189,8 +189,8 @@ async def app(client: Client, message: Message):
chat_id,
[
InputMediaPhoto(
'coverImage.jpg',
caption=f'<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>IsFree:</b> <code>{IsFree}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}',
'cover_image.jpg',
caption=f'<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>is_free:</b> <code>{is_free}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}',
)
],
)
@@ -202,16 +202,16 @@ async def app(client: Client, message: Message):
chat_id,
[
InputMediaPhoto(
'coverImage.jpg',
caption=f'<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>IsFree:</b> <code>{IsFree}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}',
'cover_image.jpg',
caption=f'<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>is_free:</b> <code>{is_free}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}',
)
],
)
except Exception as e:
await message.edit_text(format_exc(e))
finally:
if os.path.exists('coverImage.jpg'):
os.remove('coverImage.jpg')
if os.path.exists('cover_image.jpg'):
os.remove('cover_image.jpg')
@Client.on_message(filters.command('tsearch', prefix) & filters.me)
@@ -232,7 +232,7 @@ async def tsearch(client: Client, message: Message):
result = response.json()
coverImage_url = result['results'][0]['thumbnail']
cover_image_url = result['results'][0]['thumbnail']
description = result['results'][0]['description']
genre = result['results'][0]['genre']
category = result['results'][0]['category']
@@ -264,17 +264,17 @@ async def tsearch(client: Client, message: Message):
content=all_results_content,
)
if coverImage_url is not None:
coverImage = requests.get(url=coverImage_url, timeout=10).content
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
await f.write(coverImage)
if cover_image_url is not None:
cover_image = requests.get(url=cover_image_url, timeout=10).content
async with aiofiles.open('cover_image.jpg', mode='wb') as f:
await f.write(cover_image)
await message.delete()
await client.send_media_group(
chat_id,
[
InputMediaPhoto(
'coverImage.jpg',
'cover_image.jpg',
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>\n<b>More Results:</b> <a href='{link_results}'>Click Here</a>",
)
],
@@ -292,7 +292,7 @@ async def tsearch(client: Client, message: Message):
chat_id,
[
InputMediaPhoto(
'coverImage.jpg',
'cover_image.jpg',
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>",
)
],
@@ -308,8 +308,8 @@ async def tsearch(client: Client, message: Message):
except Exception as e:
await message.edit_text(format_exc(e))
finally:
if os.path.exists('coverImage.jpg'):
os.remove('coverImage.jpg')
if os.path.exists('cover_image.jpg'):
os.remove('cover_image.jpg')
@Client.on_message(filters.command('stts', prefix) & filters.me)
+1 -1
View File
@@ -53,7 +53,7 @@ async def user_exec(_: Client, message: Message):
# noinspection PyUnusedLocal
@Client.on_message(filters.command(['ev', 'eval'], prefix) & filters.me)
async def user_eval(client: Client, message: Message):
async def user_eval(_client: Client, message: Message):
if len(message.command) == 1:
await message.edit("<b>Code to eval isn't provided</b>")
return
+14 -13
View File
@@ -119,22 +119,23 @@ async def rmbg(client: Client, message: Message):
start = datetime.now()
await pablo.edit('sending to ReMove.BG')
input_file_name = cool
files = {
'image_file': (input_file_name, open(input_file_name, 'rb')),
}
r = requests.post(
'https://api.remove.bg/v1.0/removebg',
headers={'X-Api-Key': rmbg_key},
files=files,
allow_redirects=True,
stream=True,
timeout=10,
)
with open(input_file_name, 'rb') as f:
files = {
'image_file': (input_file_name, f),
}
r = requests.post(
'https://api.remove.bg/v1.0/removebg',
headers={'X-Api-Key': rmbg_key},
files=files,
allow_redirects=True,
stream=True,
timeout=10,
)
if os.path.exists(cool):
os.remove(cool)
output_file_name = r
contentType = output_file_name.headers.get('content-type')
if 'image' in contentType:
content_type = output_file_name.headers.get('content-type')
if 'image' in content_type:
with io.BytesIO(output_file_name.content) as remove_bg_image:
remove_bg_image.name = 'BG_rem.png'
await client.send_document(message.chat.id, remove_bg_image, reply_to_message_id=message.id)
+3 -2
View File
@@ -67,8 +67,9 @@ async def ipinfo(_, message: Message):
await m.edit_text('🔎')
try:
url = requests.get(
f'http://ip-api.com/json/{searchip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query'
, timeout=10)
f'http://ip-api.com/json/{searchip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query',
timeout=10,
)
response = json.loads(url.text)
text = f"""
<b>IP Address:</b> <code>{response['query']}</code>
+2 -1
View File
@@ -102,7 +102,8 @@ async def spin_handler(client: Client, message: Message):
elif message.reply_to_message.text:
result = await quote_cmd(client, message)
filename = 'sticker.png' if result[1] else 'sticker.webp'
open('downloads/' + filename, 'wb').write(result[0].getbuffer())
with open('downloads/' + filename, 'wb') as f:
f.write(result[0].getbuffer())
coro = False
else:
filename = 'photo.jpg'
+4 -4
View File
@@ -24,14 +24,14 @@ from utils.misc import modules_help, prefix
@Client.on_message(filters.command('setthumb', prefix) & filters.me)
async def setthumb(_, message: Message):
THUMB_PATH = 'downloads/thumb'
thumb_path = 'downloads/thumb'
if message.reply_to_message:
if not os.path.exists(THUMB_PATH):
os.makedirs(THUMB_PATH)
if not os.path.exists(thumb_path):
os.makedirs(thumb_path)
new_thumb = await message.reply_to_message.download()
with Image.open(new_thumb) as img:
if img.format in ['PNG', 'JPG', 'JPEG']:
new_path = os.path.join(THUMB_PATH, 'thumb.jpg')
new_path = os.path.join(thumb_path, 'thumb.jpg')
os.rename(new_thumb, new_path)
await message.edit_text('Thumbnail set successfully!')
else:
+7 -5
View File
@@ -48,8 +48,9 @@ async def scan_my_file(_, message: Message):
url = 'https://www.virustotal.com/vtapi/v2/file/scan'
params = {'apikey': vak}
files = {'file': (downloaded_file_name, open(downloaded_file_name, 'rb'))}
response = requests.post(url, files=files, params=params, timeout=10)
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']
@@ -104,9 +105,10 @@ async def scan_my_large_file(_, message: Message):
url = upl_data
files = {'file': (downloaded_file_name, open(downloaded_file_name, 'rb'))}
headers = {'accept': 'application/json', 'x-apikey': vak}
response = requests.post(url, files=files, headers=headers, timeout=10)
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']