Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
illvart committed Jan 22, 2024
1 parent 0f237fb commit b031526
Show file tree
Hide file tree
Showing 22 changed files with 492 additions and 380 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ requirements-dev.txt
run.py
scripts
setup.cfg
manifest.json
version.py
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [illvart]
custom: ["https://linktr.ee/illvart"]
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Python Version**
Provide exact python version used

**Additional context**
Add any other context about the problem here.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Additional context**
Add any other context or screenshots about the feature request here.
18 changes: 18 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- accepted
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed in 7 days if no further activity occurs.
To prevent this from happening, leave a comment.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
Closing this issue because it has been marked as stale for more than 7 days.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI
on: [push, pull_request, workflow_dispatch]
jobs:
linter:
name: Run linting and format code
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: styfle/cancel-workflow-action@0.12.0
with:
all_but_latest: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python3 -m pip install -U pip
pip3 install -r requirements.txt
if [ -f requirements-dev.txt ]; then pip3 install -r requirements-dev.txt; fi
- name: Linting and format code
run: python3 -m run --lint
- uses: illvart/beautysh-action@latest
with:
args: "*.sh --indent-size 2 &>/dev/null"
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[action] ci: auto-fixes"
commit_options: "--no-verify"
commit_user_name: kastaid
commit_user_email: illvart@protonmail.com
commit_author: kastaid <illvart@protonmail.com>
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM python:3.10-slim-bullseye
FROM python:3.11-slim-bookworm

ENV TZ=Asia/Jakarta \
TERM=xterm-256color \
DEBIAN_FRONTEND=noninteractive \
PIP_NO_CACHE_DIR=1 \
VIRTUAL_ENV=/venv \
PATH=/venv/bin:/app/bin:$PATH
VIRTUAL_ENV=/opt/venv \
PATH=/opt/venv/bin:/app/bin:$PATH

WORKDIR /app
COPY . .
Expand All @@ -17,8 +16,8 @@ RUN set -ex \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& dpkg-reconfigure --force -f noninteractive tzdata >/dev/null 2>&1 \
&& python3 -m venv $VIRTUAL_ENV \
&& pip3 install --disable-pip-version-check --default-timeout=100 --no-cache-dir -r requirements.txt \
&& pip3 install --disable-pip-version-check --default-timeout=100 -r requirements.txt \
&& apt-get -qqy clean \
&& rm -rf -- ~/.cache /var/lib/apt/lists/* /var/cache/apt/archives/* /etc/apt/sources.list.d/* /usr/share/man/* /usr/share/doc/* /var/log/* /tmp/* /var/tmp/*
&& rm -rf -- /var/lib/apt/lists/* /var/cache/apt/archives/* /etc/apt/sources.list.d/* /usr/share/man/* /usr/share/doc/* /var/log/* /tmp/* /var/tmp/*

CMD ["python3", "-m", "ds"]
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
> Pyrogram **userbot** for delay spam a message with multi chats.
<p align="center">
<a href="https://github.com/kastaid/ds/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/kastaid/ds/ci.yml?branch=main&logo=github&label=CI" /></a>
<img alt="Version" src="https://img.shields.io/github/manifest-json/v/kastaid/ds" />
<a href="https://github.com/kastaid/ds/blob/main/LICENSE"><img alt="LICENSE" src="https://img.shields.io/github/license/kastaid/ds" /></a>
<a href="https://telegram.me/kastaid"><img alt="Telegram" src="https://img.shields.io/badge/kastaid-blue?logo=telegram" /></a>
Expand All @@ -26,15 +27,21 @@ HANDLER=
```sh
git pull \
&& docker system prune -f \
&& docker compose up --detach --build --remove-orphans --no-color \
&& docker compose up --detach --build --remove-orphans \
&& docker compose logs -f
```

## commands
Please read how to at [delayspam.py](https://github.com/kastaid/ds/blob/main/ds/plugins/delayspam.py).
```sh
ds 5 10 ok
ds1 9 5 cool

dscancel
ds1cancel

dsstop
ds1stop

dsclear
```
15 changes: 5 additions & 10 deletions ds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,25 @@
# Please read the MIT License in
# < https://github.com/kastaid/ds/blob/main/LICENSE/ >.

from asyncio import set_event_loop
from multiprocessing import cpu_count
from os import cpu_count
from pathlib import Path
from shutil import rmtree
from time import time
import uvloop
from version import __version__

PROJECT = "ds"
StartTime = time()
Root: Path = Path(__file__).parent.parent
LOOP = uvloop.new_event_loop()
set_event_loop(LOOP)
WORKERS = cpu_count() * 5
WORKERS = min(32, (cpu_count() or 1) + 4)

DIRS = ("logs/",)
for d in DIRS:
for d in ("logs/",):
if not (Root / d).exists():
(Root / d).mkdir(parents=True, exist_ok=True)
else:
for _ in (Root / d).rglob("*"):
if _.is_dir():
rmtree(_)
rmtree(_, ignore_errors=True)
else:
_.unlink(missing_ok=True)

del set_event_loop, uvloop, Path, cpu_count, rmtree, time
del cpu_count, Path, rmtree, time
30 changes: 12 additions & 18 deletions ds/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,33 @@
# Please read the MIT License in
# < https://github.com/kastaid/ds/blob/main/LICENSE/ >.

import asyncio
import sys
from pyrogram.raw.functions.account import DeleteAccount
import uvloop
from pyrogram.sync import idle
from . import LOOP
from .bot import User
from .logger import LOGS

DeleteAccount.__new__ = None
from ds.logger import LOG
from ds.patcher import * # noqa
from ds.user import UserClient


async def main() -> None:
await User.start()
await UserClient().start()
await idle()
await User.stop()
await UserClient().stop()


if __name__ == "__main__":
try:
LOOP.run_until_complete(main())
uvloop.run(main())
except (
ConnectionError,
TimeoutError,
asyncio.exceptions.CancelledError,
KeyboardInterrupt,
SystemExit,
):
pass
except RuntimeError as err:
LOGS.warning(f"[MAIN_WARNING] : {err}")
except ImportError as err:
LOGS.exception(f"[MAIN_MODULE_IMPORT] : {err}")
LOG.exception(f"[MAIN_MODULE_IMPORT] : {err}")
sys.exit(1)
except Exception as err:
LOGS.exception(f"[MAIN_ERROR] : {err}")
LOG.exception(f"[MAIN_ERROR] : {err}")
finally:
LOGS.warning("[MAIN] - Stopped...")
LOG.warning("[MAIN] - Stopped...")
sys.exit(0)
90 changes: 0 additions & 90 deletions ds/bot.py

This file was deleted.

8 changes: 4 additions & 4 deletions ds/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# < https://github.com/kastaid/ds/blob/main/LICENSE/ >.

from os import getenv
import dotenv
from . import WORKERS
from dotenv import load_dotenv, find_dotenv
from ds import WORKERS

dotenv.load_dotenv(dotenv.find_dotenv("config.env"))
load_dotenv(find_dotenv("config.env"))


def tobool(val: str) -> int:
Expand All @@ -34,4 +34,4 @@ class Var:
HANDLER: str = getenv("HANDLER", "").strip()


del dotenv, WORKERS
del load_dotenv, find_dotenv, WORKERS
Loading

0 comments on commit b031526

Please sign in to comment.