Skip to content

Commit 3407c1a

Browse files
committed
Release v0.4.0
2 parents c23b88a + 72c4288 commit 3407c1a

15 files changed

Lines changed: 444 additions & 209 deletions

.gitignore

Lines changed: 98 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
# ---> Python
12
# Byte-compiled / optimized / DLL files
23
__pycache__/
3-
*.py[cod]
4+
*.py[codz]
45
*$py.class
56

67
# C extensions
@@ -20,16 +21,15 @@ parts/
2021
sdist/
2122
var/
2223
wheels/
23-
pip-wheel-metadata/
2424
share/python-wheels/
2525
*.egg-info/
2626
.installed.cfg
2727
*.egg
2828
MANIFEST
2929

3030
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3333
*.manifest
3434
*.spec
3535

@@ -47,9 +47,10 @@ htmlcov/
4747
nosetests.xml
4848
coverage.xml
4949
*.cover
50-
*.py,cover
50+
*.py.cover
5151
.hypothesis/
5252
.pytest_cache/
53+
cover/
5354

5455
# Translations
5556
*.mo
@@ -72,6 +73,7 @@ instance/
7273
docs/_build/
7374

7475
# PyBuilder
76+
.pybuilder/
7577
target/
7678

7779
# Jupyter Notebook
@@ -82,27 +84,73 @@ profile_default/
8284
ipython_config.py
8385

8486
# pyenv
85-
.python-version
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
8690

8791
# pipenv
8892
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
8993
# However, in case of collaboration, if having platform-specific dependencies or dependencies
9094
# having no cross-platform support, pipenv may install dependencies that don't work, or not
9195
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
96+
# Pipfile.lock
97+
98+
# UV
99+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# uv.lock
103+
104+
# poetry
105+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106+
# This is especially recommended for binary packages to ensure reproducibility, and is more
107+
# commonly ignored for libraries.
108+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109+
# poetry.lock
110+
# poetry.toml
111+
112+
# pdm
113+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116+
# pdm.lock
117+
# pdm.toml
118+
.pdm-python
119+
.pdm-build/
120+
121+
# pixi
122+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123+
# pixi.lock
124+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125+
# in the .venv directory. It is recommended not to include this directory in version control.
126+
.pixi
127+
128+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
95129
__pypackages__/
96130

97131
# Celery stuff
98132
celerybeat-schedule
99133
celerybeat.pid
100134

135+
# Redis
136+
*.rdb
137+
*.aof
138+
*.pid
139+
140+
# RabbitMQ
141+
mnesia/
142+
rabbitmq/
143+
rabbitmq-data/
144+
145+
# ActiveMQ
146+
activemq-data/
147+
101148
# SageMath parsed files
102149
*.sage.py
103150

104151
# Environments
105152
.env
153+
.envrc
106154
.venv
107155
env/
108156
venv/
@@ -128,12 +176,46 @@ dmypy.json
128176
# Pyre type checker
129177
.pyre/
130178

131-
.progress
132-
.vscode/*
179+
# pytype static type analyzer
180+
.pytype/
181+
182+
# Cython debug symbols
183+
cython_debug/
184+
185+
# PyCharm
186+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
187+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
188+
# and can be added to the global gitignore or merged into this file. For a more nuclear
189+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
190+
# .idea/
191+
192+
# Abstra
193+
# Abstra is an AI-powered process automation framework.
194+
# Ignore directories containing user credentials, local state, and settings.
195+
# Learn more at https://abstra.io/docs
196+
.abstra/
197+
198+
# Visual Studio Code
199+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
200+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
201+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
202+
# you could uncomment the following to ignore the entire vscode folder
203+
# .vscode/
204+
205+
# Ruff stuff:
206+
.ruff_cache/
207+
208+
# PyPI configuration file
209+
.pypirc
210+
211+
# Marimo
212+
marimo/_static/
213+
marimo/_lsp/
214+
__marimo__/
215+
216+
# Streamlit
217+
.streamlit/secrets.toml
133218

134219
logs
135-
*.db
136-
*.session*
137-
alembic*
138-
unknown_errors.txt
139-
.ruff*
220+
*.db*
221+
data

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ cd ds
4545

4646
#### String Session
4747

48-
Generate `STRING_SESSION` by choosing **Pyrofork** at [@strgen_bot](https://t.me/strgen_bot).
48+
Generate `STRING_SESSION` by running `python3 strgen.py`.
4949

5050
#### Config
5151

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ services:
99
restart: unless-stopped
1010

1111
volumes:
12-
- ./:/app
12+
- ./logs:/app/logs
13+
- ./data:/app/data
1314
env_file:
1415
- .env
1516
network_mode: bridge

ds/__init__.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@
33
# MIT License
44

55
from pathlib import Path
6-
from shutil import rmtree
76
from time import monotonic
87

98
from version import __version__ # noqa
109

1110
PROJECT = "ds"
11+
1212
StartTime = monotonic()
13+
1314
Root = Path(__file__).parent.parent
14-
WORKERS = 3
15-
16-
DIRS = ("logs/",)
17-
for d in DIRS:
18-
if not (Root / d).exists():
19-
(Root / d).mkdir(parents=True, exist_ok=True)
20-
else:
21-
for i in (Root / d).rglob("*"):
22-
if i.is_dir():
23-
rmtree(i, ignore_errors=True)
24-
else:
25-
i.unlink(missing_ok=True)
26-
27-
del Path, rmtree, monotonic
15+
LOG_DIR = Root / "logs"
16+
DATA_DIR = Root / "data"
17+
18+
19+
def ensure_dir(path: Path) -> None:
20+
path.mkdir(parents=True, exist_ok=True)
21+
22+
23+
def clean_files(path: Path) -> None:
24+
if not path.exists():
25+
return
26+
for i in path.rglob("*"):
27+
if i.is_file():
28+
i.unlink(missing_ok=True)
29+
30+
31+
for path in (
32+
LOG_DIR,
33+
DATA_DIR,
34+
):
35+
ensure_dir(path)

ds/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ async def main() -> None:
2323
try:
2424
uvloop.run(main())
2525
except KeyboardInterrupt:
26-
LOG.warning("[APP] Shutdown signal received.")
27-
except Exception as err:
28-
LOG.exception(f"[APP] Unhandled exception: {err}")
26+
LOG.info("[APP] shutdown signal received")
27+
except Exception:
28+
LOG.exception("[APP] unhandled exception")
2929
sys.exit(1)
3030
finally:
31-
LOG.warning("[APP] Stopped.")
31+
LOG.info("[APP] stopped")

ds/config.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# ruff: noqa: RUF012
21
# Copyright (C) 2023-present kastaid
32
# https://github.com/kastaid/ds
43
# MIT License
@@ -7,7 +6,7 @@
76

87
from dotenv import load_dotenv
98

10-
from . import WORKERS, Root
9+
from . import Root
1110

1211
load_dotenv(Root / ".env", override=True)
1312

@@ -27,13 +26,9 @@ def env(key: str, default: str = "") -> str:
2726

2827
class Var:
2928
DEV_MODE: bool = to_bool(env("DEV_MODE", "false"))
29+
WORKERS: int = int(env("WORKERS", "3"))
3030
API_ID: int = int(env("API_ID", "0"))
3131
API_HASH: str = env("API_HASH", "")
3232
STRING_SESSION: str = env("STRING_SESSION", "")
3333
HANDLER: str = env("HANDLER", "")
34-
WORKERS: int = int(env("WORKERS", str(WORKERS)))
3534
IS_STARTUP: bool = False
36-
ERROR_RETRY: dict[int, int] = {}
37-
38-
39-
del load_dotenv, WORKERS, Root

0 commit comments

Comments
 (0)