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:
+42
-48
@@ -15,15 +15,14 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from utils.misc import modules_help, prefix, requirements_list
|
||||
from utils.db import db
|
||||
from utils.misc import modules_help, prefix, requirements_list
|
||||
from utils.scripts import format_exc, restart
|
||||
|
||||
|
||||
@@ -31,87 +30,82 @@ def check_command(command):
|
||||
return shutil.which(command) is not None
|
||||
|
||||
|
||||
@Client.on_message(filters.command("restart", prefix) & filters.me)
|
||||
@Client.on_message(filters.command('restart', prefix) & filters.me)
|
||||
async def restart_cmd(_, message: Message):
|
||||
db.set(
|
||||
"core.updater",
|
||||
"restart_info",
|
||||
'core.updater',
|
||||
'restart_info',
|
||||
{
|
||||
"type": "restart",
|
||||
"chat_id": message.chat.id,
|
||||
"message_id": message.id,
|
||||
'type': 'restart',
|
||||
'chat_id': message.chat.id,
|
||||
'message_id': message.id,
|
||||
},
|
||||
)
|
||||
|
||||
if "LAVHOST" in os.environ:
|
||||
await message.edit("<b>Your lavHost is restarting...</b>")
|
||||
os.system("lavhost restart")
|
||||
if 'LAVHOST' in os.environ:
|
||||
await message.edit('<b>Your lavHost is restarting...</b>')
|
||||
os.system('lavhost restart')
|
||||
return
|
||||
|
||||
await message.edit("<b>Restarting...</b>")
|
||||
if os.path.exists("moonlogs.txt"):
|
||||
os.remove("moonlogs.txt")
|
||||
await message.edit('<b>Restarting...</b>')
|
||||
if os.path.exists('moonlogs.txt'):
|
||||
os.remove('moonlogs.txt')
|
||||
restart()
|
||||
|
||||
|
||||
@Client.on_message(filters.command("update", prefix) & filters.me)
|
||||
@Client.on_message(filters.command('update', prefix) & filters.me)
|
||||
async def update(_, message: Message):
|
||||
db.set(
|
||||
"core.updater",
|
||||
"restart_info",
|
||||
'core.updater',
|
||||
'restart_info',
|
||||
{
|
||||
"type": "update",
|
||||
"chat_id": message.chat.id,
|
||||
"message_id": message.id,
|
||||
'type': 'update',
|
||||
'chat_id': message.chat.id,
|
||||
'message_id': message.id,
|
||||
},
|
||||
)
|
||||
|
||||
if "LAVHOST" in os.environ:
|
||||
await message.edit("<b>Your lavHost is updating...</b>")
|
||||
os.system("lavhost update")
|
||||
if 'LAVHOST' in os.environ:
|
||||
await message.edit('<b>Your lavHost is updating...</b>')
|
||||
os.system('lavhost update')
|
||||
return
|
||||
|
||||
await message.edit("<b>Updating...</b>")
|
||||
await message.edit('<b>Updating...</b>')
|
||||
try:
|
||||
if not check_command("termux-setup-storage"):
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "-U", "pip"], check=True
|
||||
)
|
||||
subprocess.run(["git", "pull"], check=True)
|
||||
if not check_command('termux-setup-storage'):
|
||||
subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', 'pip'], check=True)
|
||||
subprocess.run(['git', 'pull'], check=True)
|
||||
|
||||
if (
|
||||
os.path.exists("requirements.txt")
|
||||
and os.path.getsize("requirements.txt") > 0
|
||||
):
|
||||
if os.path.exists('requirements.txt') and os.path.getsize('requirements.txt') > 0:
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
"-U",
|
||||
"-r",
|
||||
"requirements.txt",
|
||||
'-m',
|
||||
'pip',
|
||||
'install',
|
||||
'-U',
|
||||
'-r',
|
||||
'requirements.txt',
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
if requirements_list:
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "-U", *requirements_list],
|
||||
[sys.executable, '-m', 'pip', 'install', '-U', *requirements_list],
|
||||
check=True,
|
||||
)
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
db.remove("core.updater", "restart_info")
|
||||
db.remove('core.updater', 'restart_info')
|
||||
else:
|
||||
await message.edit("<b>Updating: done! Restarting...</b>")
|
||||
if os.path.exists("moonlogs.txt"):
|
||||
os.remove("moonlogs.txt")
|
||||
await message.edit('<b>Updating: done! Restarting...</b>')
|
||||
if os.path.exists('moonlogs.txt'):
|
||||
os.remove('moonlogs.txt')
|
||||
restart()
|
||||
|
||||
|
||||
modules_help["updater"] = {
|
||||
"update": "Update the userbot. If new core modules are avaliable, they will be installed",
|
||||
"restart": "Restart userbot",
|
||||
modules_help['updater'] = {
|
||||
'update': 'Update the userbot. If new core modules are avaliable, they will be installed',
|
||||
'restart': 'Restart userbot',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user