chore(userbot): apply ruff check --fix and ruff format

- ruff check --fix: 210 auto-fixed errors (import sorting, trailing
  whitespace, unused imports, f-string fixups, deprecated annotations)
- ruff format: 104 files reformatted to consistent style
- 268 non-auto-fixable issues remain (S113 requests timeout, etc.)
This commit is contained in:
2026-06-19 12:19:01 +02:00
parent 95cec59263
commit 7ba6bc44f2
104 changed files with 4338 additions and 5319 deletions
+19 -25
View File
@@ -1,60 +1,54 @@
import os
from pyrogram import Client, filters, enums
from pyrogram.types import Message
from pyrogram import Client, enums, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
from utils.scripts import import_library
lottie = import_library("lottie")
lottie = import_library('lottie')
from lottie.exporters import exporters
from lottie.importers import importers
@Client.on_message(filters.command("destroy", prefix) & filters.me)
@Client.on_message(filters.command('destroy', prefix) & filters.me)
async def destroy_sticker(client: Client, message: Message):
"""Destroy animated stickers by modifying their animation properties"""
try:
reply = message.reply_to_message
if not reply or not reply.sticker or not reply.sticker.is_animated:
return await message.edit(
"**Please reply to an animated sticker!**",
'**Please reply to an animated sticker!**',
parse_mode=enums.ParseMode.MARKDOWN,
)
edit_msg = await message.edit(
"**🔄 Destroying sticker...**", parse_mode=enums.ParseMode.MARKDOWN
)
edit_msg = await message.edit('**🔄 Destroying sticker...**', parse_mode=enums.ParseMode.MARKDOWN)
# Download sticker
tgs_path = await reply.download()
if not tgs_path or not os.path.exists(tgs_path):
return await edit_msg.edit(
"**❌ Download failed!**", parse_mode=enums.ParseMode.MARKDOWN
)
return await edit_msg.edit('**❌ Download failed!**', parse_mode=enums.ParseMode.MARKDOWN)
# Conversion process
json_path = "temp.json"
output_path = "MoonUB.tgs"
json_path = 'temp.json'
output_path = 'MoonUB.tgs'
importer = importers.get_from_filename(tgs_path)
if not importer:
return await edit_msg.edit(
"**❌ JSON conversion failed!**", parse_mode=enums.ParseMode.MARKDOWN
)
return await edit_msg.edit('**❌ JSON conversion failed!**', parse_mode=enums.ParseMode.MARKDOWN)
animation = importer.process(tgs_path)
exporter = exporters.get_from_filename(json_path)
exporter.process(animation, json_path)
# Modify JSON data
with open(json_path, "r+") as f:
with open(json_path, 'r+') as f:
content = f.read()
modified = (
content.replace("[1]", "[2]")
.replace("[2]", "[3]")
.replace("[3]", "[4]")
.replace("[4]", "[5]")
.replace("[5]", "[6]")
content.replace('[1]', '[2]')
.replace('[2]', '[3]')
.replace('[3]', '[4]')
.replace('[4]', '[5]')
.replace('[5]', '[6]')
)
f.seek(0)
f.write(modified)
@@ -70,7 +64,7 @@ async def destroy_sticker(client: Client, message: Message):
await edit_msg.delete()
except Exception as e:
await message.edit(f"**❌ Error:** `{e}`", parse_mode=enums.ParseMode.MARKDOWN)
await message.edit(f'**❌ Error:** `{e}`', parse_mode=enums.ParseMode.MARKDOWN)
finally:
# Cleanup temporary files
for file_path in [tgs_path, json_path, output_path]:
@@ -78,7 +72,7 @@ async def destroy_sticker(client: Client, message: Message):
try:
os.remove(file_path)
except Exception as clean_error:
print(f"Cleanup error: {clean_error}")
print(f'Cleanup error: {clean_error}')
modules_help["destroy"] = {"destroy [reply]": "Modify and destroy animated stickers"}
modules_help['destroy'] = {'destroy [reply]': 'Modify and destroy animated stickers'}