/
Shadows_Developer
/
Hook-Userbot
Обзор
Документация
Войти
/
Shadows_Developer
/
Hook-Userbot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
hook/__main__.py
84 строки
2 KB
root
Initial commit: Hook Userbot
23 мар 2025, 16:44
23 мар 2025, 16:44
f375820
Код
Авторство
О чём код?
"""Entry point. Checks for user and starts main script""" import getpass import os import subprocess import sys from ._internal import restart if ( getpass.getuser() == "root" and "--root" not in " ".join(sys.argv) and all(trigger not in os.environ for trigger in {"DOCKER", "GOORM"}) ): print("🚫" * 15) print("You attempted to run Hook on behalf of root user") print("Please, create a new user and restart script") print("If this action was intentional, pass --root argument instead") print("🚫" * 15) print() print("Type force_insecure to ignore this warning") if input("> ").lower() != "force_insecure": sys.exit(1) def deps(): subprocess.run( [ sys.executable, "-m", "pip", "install", "--upgrade", "-q", "--disable-pip-version-check", "--no-warn-script-location", "-r", "requirements.txt", ], check=True, ) if sys.version_info < (3, 8, 0): print("🚫 Error: you must use at least Python version 3.8.0") elif __package__ != "hook": # In case they did python __main__.py print("🚫 Error: you cannot run this as a script; you must execute as a package") else: try: import hikkatl except Exception: pass else: try: import hikkatl # noqa: F811 if tuple(map(int, hikkatl.__version__.split("."))) < (2, 0, 4): raise ImportError import hikkapyro if tuple(map(int, hikkapyro.__version__.split("."))) < (2, 0, 103): raise ImportError except ImportError: print("🔄 Installing dependencies...") deps() restart() try: from . import log log.init() from . import main except ImportError as e: print(f"{str(e)}\n🔄 Attempting dependencies installation... Just wait ⏱") deps() restart() if "HIKKA_DO_NOT_RESTART" in os.environ: del os.environ["HIKKA_DO_NOT_RESTART"] main.hook.main() # Execute main function