Continue fixing stuff; Add okteto support (manual build as far)

pull/1/head
hikari.ftg 2022-03-22 15:03:50 +00:00
parent dd313df63d
commit f0a89808b9
9 changed files with 30 additions and 45 deletions

View File

@ -1,11 +1,6 @@
ENV TZ=Europe/Moscow FROM python:3.8
ADD . /
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ ENV OKTETO=true
&& git clone https://github.com/hikariatama/Hikka.git /root/Hikka/ \ RUN pip install -r requirements.txt
&& pip3 install --no-cache-dir -r root/Hikka/requirements.txt \ EXPOSE 8080
&& pip3 install av --no-binary av CMD ["python3", "-m", "hikka"]
WORKDIR /root/Hikka/
# start the bot
CMD ["python3", "-m", "hikka", "--root"]

View File

@ -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

View File

@ -1,8 +0,0 @@
version: "3.9"
services:
worker:
build: .
environment:
SESSION: $SESSION
API_ID: $API_ID
API_HASH: $API_HASH

View File

@ -22,7 +22,11 @@ import sys
import getpass import getpass
import os 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("!" * 30)
print("NEVER EVER RUN USERBOT FROM ROOT") print("NEVER EVER RUN USERBOT FROM ROOT")
print("THIS IS THE THREAD FOR NOT ONLY YOUR DATA, ") print("THIS IS THE THREAD FOR NOT ONLY YOUR DATA, ")
@ -53,7 +57,9 @@ else:
"Attempting dependencies installation... Just wait." "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: try:
from . import main from . import main

View File

@ -100,7 +100,9 @@ save_config_key("use_fs_for_modules", get_config_key("use_fs_for_modules"))
def gen_port(): 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 # But for own server we generate new free port, and assign to it
port = get_config_key("port") port = get_config_key("port")

View File

@ -240,7 +240,7 @@ class LoaderMod(loader.Module):
preset = "minimal" preset = "minimal"
r = await utils.run_sync( 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() r.raise_for_status()
return set(filter(lambda x: x, r.text.split("\n"))) 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: if urllib.parse.urlparse(module_name).netloc:
url = module_name url = module_name
else: 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) r = await utils.run_sync(requests.get, url)

11
okteto-stack.yaml 100644
View File

@ -0,0 +1,11 @@
name: hikka
services:
worker:
public: true
build: .
replicas: 1
ports:
- 8080
resources:
cpu: 900m
memory: 2Gi

View File

@ -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

6
run
View File

@ -1,6 +0,0 @@
echo "
█ █ █ █▄▀ █▄▀ ▄▀█
█▀█ █ █ █ █ █ █▀█
Is starting...
"
python3 -m hikka --root