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:
+26
-36
@@ -17,71 +17,65 @@
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
from utils.misc import modules_help, prefix
|
||||
from utils.scripts import format_exc, progress
|
||||
|
||||
|
||||
@Client.on_message(filters.command("upl", prefix) & filters.me)
|
||||
@Client.on_message(filters.command('upl', prefix) & filters.me)
|
||||
async def upl(client: Client, message: Message):
|
||||
if len(message.command) > 1:
|
||||
link = message.text.split(maxsplit=1)[1]
|
||||
elif message.reply_to_message:
|
||||
link = message.reply_to_message.text
|
||||
else:
|
||||
await message.edit(
|
||||
f"<b>Usage: </b><code>{prefix}upl [filepath to upload]</code>"
|
||||
)
|
||||
await message.edit(f'<b>Usage: </b><code>{prefix}upl [filepath to upload]</code>')
|
||||
return
|
||||
|
||||
if not os.path.isfile(link):
|
||||
await message.edit(
|
||||
f"<b>Error: </b><code>{link}</code> is not a valid file path."
|
||||
)
|
||||
await message.edit(f'<b>Error: </b><code>{link}</code> is not a valid file path.')
|
||||
return
|
||||
|
||||
try:
|
||||
await message.edit("<b>Uploading Now...</b>")
|
||||
await message.edit('<b>Uploading Now...</b>')
|
||||
await client.send_document(
|
||||
message.chat.id,
|
||||
link,
|
||||
progress=progress,
|
||||
progress_args=(message, time.time(), "<b>Uploading Now...</b>", link),
|
||||
progress_args=(message, time.time(), '<b>Uploading Now...</b>', link),
|
||||
)
|
||||
await message.delete()
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
|
||||
@Client.on_message(filters.command("dlf", prefix) & filters.me)
|
||||
@Client.on_message(filters.command('dlf', prefix) & filters.me)
|
||||
async def dlf(client: Client, message: Message):
|
||||
if message.reply_to_message:
|
||||
await client.download_media(
|
||||
message.reply_to_message,
|
||||
progress=progress,
|
||||
progress_args=(message, time.time(), "<b>Uploading Now...</b>"),
|
||||
progress_args=(message, time.time(), '<b>Uploading Now...</b>'),
|
||||
)
|
||||
await message.edit("<b>Downloaded Successfully!</b>")
|
||||
await message.edit('<b>Downloaded Successfully!</b>')
|
||||
else:
|
||||
await message.edit(f"<b>Usage: </b><code>{prefix}dlf [reply to a file]</code>")
|
||||
await message.edit(f'<b>Usage: </b><code>{prefix}dlf [reply to a file]</code>')
|
||||
|
||||
|
||||
@Client.on_message(filters.command("moonlogs", prefix) & filters.me)
|
||||
@Client.on_message(filters.command('moonlogs', prefix) & filters.me)
|
||||
async def mupl(client: Client, message: Message):
|
||||
link = "moonlogs.txt"
|
||||
link = 'moonlogs.txt'
|
||||
if os.path.exists(link):
|
||||
try:
|
||||
await message.edit("<b>Uploading Now...</b>")
|
||||
with open(link, "rb") as f:
|
||||
await message.edit('<b>Uploading Now...</b>')
|
||||
with open(link, 'rb') as f:
|
||||
data = f.read()
|
||||
bio = io.BytesIO(data)
|
||||
bio.name = "moonlogs.txt"
|
||||
bio.name = 'moonlogs.txt'
|
||||
await client.send_document(
|
||||
message.chat.id,
|
||||
bio,
|
||||
progress=progress,
|
||||
progress_args=(message, time.time(), "<b>Uploading Now...</b>")
|
||||
message.chat.id, bio, progress=progress, progress_args=(message, time.time(), '<b>Uploading Now...</b>')
|
||||
)
|
||||
await message.delete()
|
||||
except Exception as e:
|
||||
@@ -90,31 +84,27 @@ async def mupl(client: Client, message: Message):
|
||||
await message.edit("<b>Error: </b><code>LOGS</code> file doesn't exist.")
|
||||
|
||||
|
||||
@Client.on_message(filters.command("uplr", prefix) & filters.me)
|
||||
@Client.on_message(filters.command('uplr', prefix) & filters.me)
|
||||
async def uplr(client: Client, message: Message):
|
||||
if len(message.command) > 1:
|
||||
link = message.text.split(maxsplit=1)[1]
|
||||
elif message.reply_to_message:
|
||||
link = message.reply_to_message.text
|
||||
else:
|
||||
await message.edit(
|
||||
f"<b>Usage: </b><code>{prefix}upl [filepath to upload]</code>"
|
||||
)
|
||||
await message.edit(f'<b>Usage: </b><code>{prefix}upl [filepath to upload]</code>')
|
||||
return
|
||||
|
||||
if not os.path.isfile(link):
|
||||
await message.edit(
|
||||
f"<b>Error: </b><code>{link}</code> is not a valid file path."
|
||||
)
|
||||
await message.edit(f'<b>Error: </b><code>{link}</code> is not a valid file path.')
|
||||
return
|
||||
|
||||
try:
|
||||
await message.edit("<b>Uploading Now...</b>")
|
||||
await message.edit('<b>Uploading Now...</b>')
|
||||
await client.send_document(
|
||||
message.chat.id,
|
||||
link,
|
||||
progress=progress,
|
||||
progress_args=(message, time.time(), "<b>Uploading Now...</b>", link),
|
||||
progress_args=(message, time.time(), '<b>Uploading Now...</b>', link),
|
||||
)
|
||||
await message.delete()
|
||||
except Exception as e:
|
||||
@@ -124,9 +114,9 @@ async def uplr(client: Client, message: Message):
|
||||
os.remove(link)
|
||||
|
||||
|
||||
modules_help["uplud"] = {
|
||||
"upl [filepath]/[reply to path]*": "Upload a file from your local machine to Telegram",
|
||||
"dlf": "Download a file from Telegram to your local machine",
|
||||
"uplr [filepath]/[reply to path]*": "Upload a file from your local machine to Telegram, delete the file after uploading",
|
||||
"moonlogs": "Upload the moonlogs.txt file to Telegram",
|
||||
modules_help['uplud'] = {
|
||||
'upl [filepath]/[reply to path]*': 'Upload a file from your local machine to Telegram',
|
||||
'dlf': 'Download a file from Telegram to your local machine',
|
||||
'uplr [filepath]/[reply to path]*': 'Upload a file from your local machine to Telegram, delete the file after uploading',
|
||||
'moonlogs': 'Upload the moonlogs.txt file to Telegram',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user