Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.12', '3.14']
python-version: ['3.13', '3.14']
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12.2
3.13
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# AGPL-3.0 License

FROM mwader/static-ffmpeg:7.1.1 AS builder_ffmpeg
FROM python:3.12-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:0.10.8 /uv /uvx /bin/
FROM python:3.13-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:0.10.9 /uv /uvx /bin/
ENV TERM=xterm \
PATH=/opt/venv/bin:$PATH \
UV_LINK_MODE=copy \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.lite
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# AGPL-3.0 License

FROM mwader/static-ffmpeg:7.1.1 AS builder_ffmpeg
FROM python:3.12-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:0.10.8 /uv /uvx /bin/
FROM python:3.13-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:0.10.9 /uv /uvx /bin/
ENV TERM=xterm \
PATH=/opt/venv/bin:$PATH \
UV_LINK_MODE=copy \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Thank you for trusting and using this userbot!

## Requirements

- Python 3.12.x
- Python 3.13+
- Linux (recommended: latest Debian/Ubuntu)
- Telegram `API_ID` and `API_HASH` from [API development tools](https://my.telegram.org)

Expand Down
3 changes: 1 addition & 2 deletions getter/core/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
Var,
hl,
)
from getter.logger import LOG, TelethonLogger
from getter.logger import LOG

from .db import sgvar
from .functions import display_name
Expand Down Expand Up @@ -79,7 +79,6 @@ def __init__(
kwargs["system_version"] = " ".join((version(), machine()))
kwargs["app_version"] = __version__
kwargs["loop"] = LOOP
kwargs["base_logger"] = TelethonLogger
kwargs["entity_cache_limit"] = 1000
super().__init__(session, *args, **kwargs)
self.__class__.__module__ = "telethon.client.telegramclient"
Expand Down
52 changes: 40 additions & 12 deletions getter/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,42 @@

import logging
import sys
from datetime import date
from datetime import UTC, datetime

from loguru import logger as LOG

LOG.remove(0)
LOG.remove()
LOG.add(
"logs/getter-{}.log".format(date.today().strftime("%Y-%m-%d")),
format="{time:YY/MM/DD HH:mm:ss} | {level: <8} | {name: ^15} | {function: ^15} | {line: >3} : {message}",
rotation="1 MB",
f"logs/getter-{datetime.now(UTC):%Y-%m-%d}.log",
format="{time:YYYY-MM-DD HH:mm:ss} | {level:<8} | {name}:{function}:{line} | {message}",
backtrace=False,
diagnose=False,
enqueue=True,
catch=True,
rotation="3 MB",
retention="7 days",
delay=True,
)
LOG.add(
sys.stderr,
format="{time:YY/MM/DD HH:mm:ss} | {level} | {name}:{function}:{line} | {message}",
sys.stdout,
level="INFO",
format="{time:MM-DD HH:mm:ss} | {level:<8} | {message}",
filter=lambda r: r["level"].name != "ERROR",
colorize=False,
backtrace=False,
diagnose=False,
enqueue=True,
catch=True,
)
LOG.add(
sys.stderr,
level="ERROR",
format="{time:MM-DD HH:mm:ss} | {level:<8} | {name}:{function}:{line} | {message}",
colorize=False,
backtrace=False,
diagnose=False,
enqueue=True,
catch=True,
)


Expand All @@ -29,7 +49,8 @@ def emit(self, record):
level = LOG.level(record.levelname).name
except ValueError:
level = record.levelno
frame, depth = sys._getframe(6), 6
frame = sys._getframe(2)
depth = 2
while frame and frame.f_code.co_filename == logging.__file__:
frame = frame.f_back
depth += 1
Expand All @@ -40,8 +61,15 @@ def emit(self, record):
).log(level, record.getMessage())


logging.basicConfig(handlers=[InterceptHandler()], level=logging.INFO)
logging.basicConfig(
handlers=[InterceptHandler()],
level=logging.INFO,
force=True,
)
logging.disable(logging.DEBUG)
logging.getLogger("asyncio").setLevel(logging.ERROR)
TelethonLogger = logging.getLogger("telethon")
TelethonLogger.setLevel(logging.ERROR)
for name in (
"asyncio",
"telethon",
"telethon.network.mtprotosender",
):
logging.getLogger(name).setLevel(logging.ERROR)
29 changes: 25 additions & 4 deletions getter/plugins/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import asyncio
import os
import shutil
import subprocess
import sys
from random import choice
from time import monotonic, sleep as tsleep
Expand Down Expand Up @@ -203,12 +204,32 @@ def restart_app() -> None:
os.close(p.fd)
except BaseException:
pass
reqs = Root / "requirements.txt"
reqs = str(Root / "requirements.txt")
if shutil.which("uv"):
os.system(f"uv pip install -r {reqs}")
subprocess.run(
[
"uv",
"pip",
"install",
"-r",
reqs,
],
check=True,
)
else:
os.system(
f"{sys.executable} -m pip install --prefer-binary --disable-pip-version-check --default-timeout=100 -r {reqs}"
subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
"--prefer-binary",
"--disable-pip-version-check",
"--default-timeout=100",
"-r",
reqs,
],
check=True,
)
os.execl(sys.executable, sys.executable, "-m", "getter")

Expand Down
2 changes: 1 addition & 1 deletion getter/plugins/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def ignores() -> None:


async def update_packages() -> None:
reqs = Root / "requirements.txt"
reqs = str(Root / "requirements.txt")
if shutil.which("uv"):
await Runner(f"uv pip install -r {reqs}")
else:
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.3.3"
"version": "2.3.4"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
show-fixes = true
line-length = 120
indent-width = 4
target-version = "py312"
target-version = "py313"

[tool.ruff.format]
quote-style = "double"
Expand Down
Loading