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:
+10
-22
@@ -28,9 +28,7 @@ from utils.scripts import format_exc
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
@Client.on_message(
|
||||
filters.command(["ex", "exec", "py", "exnoedit"], prefix) & filters.me
|
||||
)
|
||||
@Client.on_message(filters.command(['ex', 'exec', 'py', 'exnoedit'], prefix) & filters.me)
|
||||
async def user_exec(_: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
await message.edit("<b>Code to execute isn't provided</b>")
|
||||
@@ -39,18 +37,13 @@ async def user_exec(_: Client, message: Message):
|
||||
code = message.text.split(maxsplit=1)[1]
|
||||
stdout = StringIO()
|
||||
|
||||
await message.edit("<b>Executing...</b>")
|
||||
await message.edit('<b>Executing...</b>')
|
||||
|
||||
try:
|
||||
with redirect_stdout(stdout):
|
||||
exec(code) # skipcq
|
||||
text = (
|
||||
"<b>Code:</b>\n"
|
||||
f"<code>{code}</code>\n\n"
|
||||
"<b>Result</b>:\n"
|
||||
f"<code>{stdout.getvalue()}</code>"
|
||||
)
|
||||
if message.command[0] == "exnoedit":
|
||||
text = f'<b>Code:</b>\n<code>{code}</code>\n\n<b>Result</b>:\n<code>{stdout.getvalue()}</code>'
|
||||
if message.command[0] == 'exnoedit':
|
||||
await message.reply(text)
|
||||
else:
|
||||
await message.edit(text)
|
||||
@@ -59,7 +52,7 @@ async def user_exec(_: Client, message: Message):
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
@Client.on_message(filters.command(["ev", "eval"], prefix) & filters.me)
|
||||
@Client.on_message(filters.command(['ev', 'eval'], prefix) & filters.me)
|
||||
async def user_eval(client: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
await message.edit("<b>Code to eval isn't provided</b>")
|
||||
@@ -69,18 +62,13 @@ async def user_eval(client: Client, message: Message):
|
||||
|
||||
try:
|
||||
result = eval(code) # skipcq
|
||||
await message.edit(
|
||||
"<b>Expression:</b>\n"
|
||||
f"<code>{code}</code>\n\n"
|
||||
"<b>Result</b>:\n"
|
||||
f"<code>{result}</code>"
|
||||
)
|
||||
await message.edit(f'<b>Expression:</b>\n<code>{code}</code>\n\n<b>Result</b>:\n<code>{result}</code>')
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
|
||||
modules_help["python"] = {
|
||||
"ex [python code]": "Execute Python code",
|
||||
"exnoedit [python code]": "Execute Python code and return result with reply",
|
||||
"eval [python code]": "Eval Python code",
|
||||
modules_help['python'] = {
|
||||
'ex [python code]': 'Execute Python code',
|
||||
'exnoedit [python code]': 'Execute Python code and return result with reply',
|
||||
'eval [python code]': 'Eval Python code',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user