diff --git a/docker-compose.yml b/docker-compose.yml index fd31170..d5f1187 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: postgres: image: postgres:latest @@ -10,9 +8,9 @@ services: POSTGRES_PASSWORD: meow POSTGRES_DB: tgtree ports: - - "127.0.0.1:5432:5432" + - "127.0.0.1:5444:5432" volumes: - - tgtree-db:/var/lib/postgresql/data + - tgtree-db:/var/lib/postgresql volumes: tgtree-db: diff --git a/pyproject.toml b/pyproject.toml index e3a6afe..8003140 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ dependencies = [ "hypy-utils>=1.0.29", "peewee>=4.0.1", "playhouse>=0.1.0", + "psycopg2>=2.9.11", "python-telegram-bot>=22.6", "requests>=2.32.5", "starlette>=0.52.1", diff --git a/src/bot.py b/src/bot.py index 6762c4a..81bdfeb 100644 --- a/src/bot.py +++ b/src/bot.py @@ -69,9 +69,9 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): def channel_html(channel: str): ouf = (channels_dir / f"{channel}.html") if ouf.exists(): - return ouf.read_text() + return ouf.read_text('utf-8') t = requests.get(f"https://t.me/{channel}").text - ouf.write_text(t) + ouf.write_text(t, 'utf-8') return t @@ -431,7 +431,7 @@ async def shutdown_event(): await bot.shutdown() -layout_html = (Path(__file__).parent / "public" / "layout.html").read_text() +layout_html = (Path(__file__).parent.parent / "public" / "layout.html").read_text('utf-8') fmt_html = lambda x: layout_html.replace("{{CONTENT}}", x).replace("\n", "") diff --git a/src/gentree.py b/src/gentree.py index 9fc726a..2540d95 100644 --- a/src/gentree.py +++ b/src/gentree.py @@ -29,7 +29,7 @@ def dfs(channel: str): def gen_tree(d: Path = src / "public"): of = dfs("hykilp") - write(d / "index.html", (src / "public/layout-full-tree.html").read_text() + write(d / "index.html", (src / "public/layout-full-tree.html").read_text('utf-8') .replace("{{CONTENT}}", of)) diff --git a/src/utils.py b/src/utils.py index 76cf79c..26e04dc 100644 --- a/src/utils.py +++ b/src/utils.py @@ -5,7 +5,7 @@ from pathlib import Path from typing import NamedTuple -CONFIG = tomllib.loads((Path(__file__).parent.parent / "config.toml").read_text()) +CONFIG = tomllib.loads((Path(__file__).parent.parent / "config.toml").read_text('utf-8')) def gen_sha(channel: str, uid: int, parent: str): diff --git a/uv.lock b/uv.lock index f07249a..00e3370 100644 --- a/uv.lock +++ b/uv.lock @@ -54,6 +54,7 @@ dependencies = [ { name = "hypy-utils" }, { name = "peewee" }, { name = "playhouse" }, + { name = "psycopg2" }, { name = "python-telegram-bot" }, { name = "requests" }, { name = "starlette" }, @@ -66,6 +67,7 @@ requires-dist = [ { name = "hypy-utils", specifier = ">=1.0.29" }, { name = "peewee", specifier = ">=4.0.1" }, { name = "playhouse", specifier = ">=0.1.0" }, + { name = "psycopg2", specifier = ">=2.9.11" }, { name = "python-telegram-bot", specifier = ">=22.6" }, { name = "requests", specifier = ">=2.32.5" }, { name = "starlette", specifier = ">=0.52.1" }, @@ -223,6 +225,16 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/13/22/2a61be98f9dace4604aec97eb6cae085354f04babb91de3e5b0fc3b6cc5a/playhouse-0.1.0-py3-none-any.whl", hash = "sha256:ba6b851f8bba7cf083b0289f64729b717f4e8bd552d2ba3dfc6fc1f76fdd40a1", size = 1080, upload-time = "2024-11-10T13:02:37.999Z" }, ] +[[package]] +name = "psycopg2" +version = "2.9.11" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/89/8d/9d12bc8677c24dad342ec777529bce705b3e785fa05d85122b5502b9ab55/psycopg2-2.9.11.tar.gz", hash = "sha256:964d31caf728e217c697ff77ea69c2ba0865fa41ec20bb00f0977e62fdcc52e3", size = 379598, upload-time = "2025-10-10T11:14:46.075Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/5a/18c8cb13fc6908dc41a483d2c14d927a7a3f29883748747e8cb625da6587/psycopg2-2.9.11-cp313-cp313-win_amd64.whl", hash = "sha256:8dc379166b5b7d5ea66dcebf433011dfc51a7bb8a5fc12367fa05668e5fc53c8", size = 2714048, upload-time = "2025-10-10T11:10:19.816Z" }, + { url = "https://files.pythonhosted.org/packages/47/08/737aa39c78d705a7ce58248d00eeba0e9fc36be488f9b672b88736fbb1f7/psycopg2-2.9.11-cp314-cp314-win_amd64.whl", hash = "sha256:f10a48acba5fe6e312b891f290b4d2ca595fc9a06850fe53320beac353575578", size = 2803738, upload-time = "2025-10-10T11:10:23.196Z" }, +] + [[package]] name = "pydantic" version = "2.12.5"