diff --git a/Dockerfile b/Dockerfile index fb715bf..b9e9034 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,6 @@ -ENV TZ=Europe/Moscow - -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ - && git clone https://github.com/hikariatama/Hikka.git /root/Hikka/ \ - && pip3 install --no-cache-dir -r root/Hikka/requirements.txt \ - && pip3 install av --no-binary av - -WORKDIR /root/Hikka/ - -# start the bot -CMD ["python3", "-m", "hikka", "--root"] \ No newline at end of file +FROM python:3.8 +ADD . / +ENV OKTETO=true +RUN pip install -r requirements.txt +EXPOSE 8080 +CMD ["python3", "-m", "hikka"] \ No newline at end of file diff --git a/Procfile b/Procfile deleted file mode 100755 index 20cf404..0000000 --- a/Procfile +++ /dev/null @@ -1,3 +0,0 @@ -worker-DO-NOT-TURN-ON-OR-THINGS-WILL-BREAK: python3 -m friendly-telegram -web: python3 -m friendly-telegram --heroku-web-internal -restarter-DO-NOT-TURN-ON-OR-THINGS-WILL-BREAK: python3 -m friendly-telegram --heroku-restart-internal diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 1f5ea3d..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: "3.9" -services: - worker: - build: . - environment: - SESSION: $SESSION - API_ID: $API_ID - API_HASH: $API_HASH \ No newline at end of file diff --git a/hikka/__main__.py b/hikka/__main__.py index c87387d..068184d 100755 --- a/hikka/__main__.py +++ b/hikka/__main__.py @@ -22,7 +22,11 @@ import sys import getpass import os -if getpass.getuser() == "root" and "--root" not in " ".join(sys.argv): +if ( + getpass.getuser() == "root" + and "--root" not in " ".join(sys.argv) + and "OKTETO" not in os.environ +): print("!" * 30) print("NEVER EVER RUN USERBOT FROM ROOT") print("THIS IS THE THREAD FOR NOT ONLY YOUR DATA, ") @@ -53,7 +57,9 @@ else: "Attempting dependencies installation... Just wait." ) - os.popen("pip3 install -r requirements.txt").read() # skipcq: BAN-B605, BAN-B607 + os.popen( + "pip3 install -r requirements.txt" + ).read() # skipcq: BAN-B605, BAN-B607 try: from . import main diff --git a/hikka/main.py b/hikka/main.py index 4c2cd7f..33fa678 100755 --- a/hikka/main.py +++ b/hikka/main.py @@ -100,7 +100,9 @@ save_config_key("use_fs_for_modules", get_config_key("use_fs_for_modules")) def gen_port(): - # TODO: Oktato 8080 default + if "OKTETO" in os.environ: + return 8080 + # But for own server we generate new free port, and assign to it port = get_config_key("port") diff --git a/hikka/modules/loader.py b/hikka/modules/loader.py index b3781cb..063003e 100755 --- a/hikka/modules/loader.py +++ b/hikka/modules/loader.py @@ -240,7 +240,7 @@ class LoaderMod(loader.Module): preset = "minimal" r = await utils.run_sync( - requests.get, self.config["MODULES_REPO"] + "/" + preset + ".txt" + requests.get, self.config["MODULES_REPO"].strip("/") + "/" + preset + ".txt" ) r.raise_for_status() return set(filter(lambda x: x, r.text.split("\n"))) @@ -250,7 +250,7 @@ class LoaderMod(loader.Module): if urllib.parse.urlparse(module_name).netloc: url = module_name else: - url = self.config["MODULES_REPO"] + module_name + ".py" + url = self.config["MODULES_REPO"].strip("/") + "/" + module_name + ".py" r = await utils.run_sync(requests.get, url) diff --git a/okteto-stack.yaml b/okteto-stack.yaml new file mode 100644 index 0000000..13e8b3c --- /dev/null +++ b/okteto-stack.yaml @@ -0,0 +1,11 @@ +name: hikka +services: + worker: + public: true + build: . + replicas: 1 + ports: + - 8080 + resources: + cpu: 900m + memory: 2Gi \ No newline at end of file diff --git a/okteto.yml b/okteto.yml deleted file mode 100644 index 8141a5c..0000000 --- a/okteto.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: hikka -image: python:3 -command: ["python3", "-m", "hikka", "--root"] -sync: -- .:/usr/src/app -forward: -- 8080:8080 -reverse: -- 9000:9000 -autocreate: true -volumes: -- /root/.cache/pip diff --git a/run b/run deleted file mode 100644 index 617164d..0000000 --- a/run +++ /dev/null @@ -1,6 +0,0 @@ -echo " - █ █ █ █▄▀ █▄▀ ▄▀█ - █▀█ █ █ █ █ █ █▀█ - Is starting... -" -python3 -m hikka --root \ No newline at end of file