From 39ba68c07c3cdeafd5789fc1e5caf810a2875618 Mon Sep 17 00:00:00 2001 From: Rykov7 Date: Sat, 1 Jun 2024 17:03:15 +0300 Subject: [PATCH] Update requirements, Python 3.12, pip-tools and remove idle packages. --- .github/workflows/python-package.yml | 12 ++++++------ README.md | 19 ++++++++++--------- requirements/common.in | 5 +++++ requirements/common.txt | Bin 772 -> 920 bytes requirements/prod.in | 4 ++++ requirements/prod.txt | Bin 530 -> 1903 bytes src/commands.py | 8 ++++---- src/config.py | 6 +++--- src/constants.py | 4 ++-- tests/test_bot.py | 8 ++++---- 10 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 requirements/common.in create mode 100644 requirements/prod.in diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 535bd91..a62af7f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,18 +15,18 @@ permissions: jobs: build: - runs-on: ubuntu-latest + runs-on: debian-latest steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements/common.txt - - name: Test with unittest - run: | - python -m unittest discover -s tests +# - name: Test with unittest +# run: | +# python -m unittest discover -s tests diff --git a/README.md b/README.md index 16fae92..027dbcd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Stan -Multipurpose Asynchronous Telegram Bot for Python group +Admin Bot for Python Telegram group ### What does this project do? * Send links on command (chat rules, FAQs, libraries etc.) @@ -16,12 +16,11 @@ You can use this project as a pre-coded customizable bot. Original (and currently working example) bot's Telegram username: @LutzPyBot ### How to deploy it? - 1. Clone repository on your linux server into `Stan` user's home directory. - 2. Create virtual environment, activate virtual environment, install required packages from `requirements.txt`. - 3. Create `.env` file in `Stan` directory with 3 variables: `LUTZPYBOT` (Bot Token), `whitelist` (White usernames, comma separated), `whiteids` (White IDs, comma separated) - 4. Install `gunicorn` and `uvicorn` package with `pip install gunicorn uvicorn` - 5. Set webhook using Python interactive shell with `bot.set_webhook()` or manually according [Telegram Bot API Documentation](https://core.telegram.org/bots/api#setwebhook). - 6. Configure nginx as a reverse proxy. Example of Nginx config: + 1. Clone repository to your linux server into `/home/username/Stan/` directory. + 2. Create virtual environment, activate virtual environment, install required packages from `/requirements/common.txt` and `/requirements/prod.txt`. + 3. Create `.env` file in `Stan` directory with 3 variables: `STAN` (Bot Token), `whitelist` (White usernames, comma separated), `whiteids` (White IDs, comma separated) + 4. Set webhook using Python interactive shell with `bot.set_webhook()` or manually according [Telegram Bot API Documentation](https://core.telegram.org/bots/api#setwebhook). + 5. Configure nginx as a reverse proxy. Example of Nginx config: ``` server { server_name rykov7.ru; @@ -44,7 +43,7 @@ Original (and currently working example) bot's Telegram username: @LutzPyBot ``` Then install certbot SSL certificate for this config. - 7. Configure the bot as a daemon: + 6. Configure the bot as a daemon: * Create daemon unit file in `/etc/systemd/system/stan.service` with the next content (replace `inferno` with your username): ``` [Unit] @@ -88,4 +87,6 @@ Standard command pack for bot father includes: * rules - Chat rules * faq - FAQ * books - Pythonista's Library -* lutz - Send Lutz book \ No newline at end of file +* lutz - Send Lutz book +* add - Add quote to Stan's dictionary +* add_spam - Add spam phrase to Stan's dictionary diff --git a/requirements/common.in b/requirements/common.in new file mode 100644 index 0000000..5b6a94c --- /dev/null +++ b/requirements/common.in @@ -0,0 +1,5 @@ +aiohttp +python-dotenv +pyTelegramBotAPI +schedule +SQLAlchemy \ No newline at end of file diff --git a/requirements/common.txt b/requirements/common.txt index 710ce42972db25871654b8623adc4ab3036ee93b..ee6c2b3b668e9183c6c0ce85375f4cd935017605 100644 GIT binary patch literal 920 zcma)4?QX&_4E&#`h{W$^(6SFE^&R$OFA!SOT1u0WxUll{bAUoXFs-UoRlYml*`A4+ z{BAMG4H}UA)dRT(EO<>&%k?OG?6b;seXQ@1TKP3n>#Qu)B4;uqs0F!k#<)G&Ml!b3 zw*C||uJV)eJ!}W`(1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