From 27dcf5c764caae182c876e53d4b644cdda09165f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 30 Jul 2020 23:15:33 +0200 Subject: [PATCH 01/15] Create check Github Action --- .github/workflows/check.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..1888e0e0 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,24 @@ +name: Syntax check + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Check commands + run: python -m py_compile royalpack/commands/__init__.py + - name: Check events + run: python -m py_compile royalpack/events/__init__.py + - name: Check stars + run: python -m py_compile royalpack/stars/__init__.py + - name: Check tables + run: python -m py_compile royalpack/tables/__init__.py From 88db931584489f3fc8be776cbcc8bc1a568a3f4c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 30 Jul 2020 23:27:16 +0200 Subject: [PATCH 02/15] Try using compileall instead of py_compile --- .github/workflows/check.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1888e0e0..1fb3926f 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -14,11 +14,5 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.8' - - name: Check commands - run: python -m py_compile royalpack/commands/__init__.py - - name: Check events - run: python -m py_compile royalpack/events/__init__.py - - name: Check stars - run: python -m py_compile royalpack/stars/__init__.py - - name: Check tables - run: python -m py_compile royalpack/tables/__init__.py + - name: Check everything + run: python -m compileall royalpack From aa64f3b8548893e276c97a4d40fe2702a7ed8313 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 00:55:54 +0200 Subject: [PATCH 03/15] Better describe the steps in the check workflow --- .github/workflows/check.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1fb3926f..ca97a148 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -10,9 +10,11 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Install Python 3.8 + uses: actions/setup-python@v2 with: python-version: '3.8' - - name: Check everything + - name: Check all .py files run: python -m compileall royalpack From 775278ade2809248b758946eb4e731ff5cd9322e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 00:56:46 +0200 Subject: [PATCH 04/15] Create publish to pypi workflow --- .github/workflows/publish.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..c1e45f60 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Publish to PyPI + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Setup Python and Poetry + uses: abatilo/actions-poetry@v1.5.0 + with: + python_version: 3.8 + poetry_version: 1.0 + args: install + - name: Build + run: poetry build + - name: Publish + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_USERNAME }} + run: poetry publish From 1bd2bee99f6d921c3be28f419fcaf1f8ed8eb911 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 00:57:24 +0200 Subject: [PATCH 05/15] Fix secret name in the publish workflow --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c1e45f60..17cd4854 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,5 +20,5 @@ jobs: run: poetry build - name: Publish env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_USERNAME }} + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }} run: poetry publish From 8400f011ddad6bb5497e25c218ebb8e7731f31d2 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 01:12:53 +0200 Subject: [PATCH 06/15] Let's see what happens if i bump the version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9dbe6bf6..97274e07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [tool.poetry] name = "royalpack" - version = "5.13.4" + version = "5.13.5" description = "A Royalnet command pack for the Royal Games community" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" From 4fe8fb022f3f6dbbbfc5f80a196ba50d4f66f052 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 01:40:58 +0200 Subject: [PATCH 07/15] Maybe like this? --- .github/workflows/publish.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 17cd4854..17496f3e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,15 +10,11 @@ jobs: steps: - name: Checkout the repository uses: actions/checkout@v2 - - name: Setup Python and Poetry + - name: Build and publish the package uses: abatilo/actions-poetry@v1.5.0 + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }} with: python_version: 3.8 poetry_version: 1.0 - args: install - - name: Build - run: poetry build - - name: Publish - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }} - run: poetry publish + args: publish --build From 3cbe2caa8c8e39c9928026c5213ed1d1b05e76c3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 01:41:40 +0200 Subject: [PATCH 08/15] Bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 97274e07..117b1a32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [tool.poetry] name = "royalpack" - version = "5.13.5" + version = "5.13.6" description = "A Royalnet command pack for the Royal Games community" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" From c426bbc3177e0bd54ead36f9ef41c86522abdcfa Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 01:55:42 +0200 Subject: [PATCH 09/15] visible confusion --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 117b1a32..d7de0b5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [tool.poetry] name = "royalpack" - version = "5.13.6" + version = "5.13.69" description = "A Royalnet command pack for the Royal Games community" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" From 235af5dba64b2e9c3b15a0c7622cb38339b99a4f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 03:27:51 +0200 Subject: [PATCH 10/15] Aggiungi nuove fortune --- royalpack/commands/fortune.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/royalpack/commands/fortune.py b/royalpack/commands/fortune.py index d662a1b8..b386b9d4 100644 --- a/royalpack/commands/fortune.py +++ b/royalpack/commands/fortune.py @@ -33,12 +33,19 @@ class FortuneCommand(rc.Command): "⭐️ Oggi la stella della RYG ti sembrerà un pochino più dritta!", "⭐️ Oggi la stella della RYG ti sembrerà anche più storta del solito!", "💎 Oggi i tuoi avversari non riusciranno a deflettere i tuoi Emerald Splash!", + "⁉️ Oggi le tue supercazzole prematureranno un po' più a destra!", "⁉️ Oggi le tue supercazzole prematureranno un po' più a sinistra!", "🌅 Oggi sarà il giorno dopo ieri e il giorno prima di domani!", "🤖 Oggi il Royal Bot ti dirà qualcosa di molto utile!", "💤 Oggi rischierai di addormentarti più volte!", "🥪 Oggi ti verrà fame fuori orario!", "😓 Oggi dirai molte stupidaggini!", + "🏠 Oggi qualcuno si autoinviterà a casa tua!", + "📵 Oggi passerai una bella giornata tranquilla senza che nessuno ti chiami!", + "🎶 Oggi scoprirai un vero [url=https://www.urbandictionary.com/define.php?term=banger]banger[/url]!", + "🕸 Oggi cadrai trappola di una ragnatela! [i]O ti arriverà in faccia.[/i]", + "🧻 Oggi fai attenzione alla carta igienica: potrebbe finire!", + "🔮 Oggi chiederai a @royalgamesbot di dirti la tua /fortune!" ] async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: From 5001f8f7c77aa1b0b31a8318eef55839a78148ac Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 03:35:06 +0200 Subject: [PATCH 11/15] Fix typos --- royalpack/commands/fortune.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/royalpack/commands/fortune.py b/royalpack/commands/fortune.py index b386b9d4..b4555aaa 100644 --- a/royalpack/commands/fortune.py +++ b/royalpack/commands/fortune.py @@ -45,7 +45,8 @@ class FortuneCommand(rc.Command): "🎶 Oggi scoprirai un vero [url=https://www.urbandictionary.com/define.php?term=banger]banger[/url]!", "🕸 Oggi cadrai trappola di una ragnatela! [i]O ti arriverà in faccia.[/i]", "🧻 Oggi fai attenzione alla carta igienica: potrebbe finire!", - "🔮 Oggi chiederai a @royalgamesbot di dirti la tua /fortune!" + "🔮 Oggi chiederai a @royalgamesbot di dirti la tua /fortune!", + "🧨 Oggi calpesterai delle [url=https://www.youtube.com/watch?v=Zyef3NU3wqk&t=57]mine di Techies[/url]!", ] async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: From 64f517ea625e0bb42a2c861fc18ebabcf1967ab1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 16:06:28 +0200 Subject: [PATCH 12/15] Update dependencies --- poetry.lock | 14 +++++++++++++- pyproject.toml | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 378d7827..1d194772 100644 --- a/poetry.lock +++ b/poetry.lock @@ -272,6 +272,14 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.10" +[[package]] +category = "main" +description = "Various helpers to pass data to untrusted environments and back." +name = "itsdangerous" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "1.1.0" + [[package]] category = "main" description = "multidict implementation" @@ -713,7 +721,7 @@ python-versions = "*" version = "2020.6.16.1" [metadata] -content-hash = "6186dd82fb955af7343f43eaddc27c2eb6b9abe24b53e34bc41891e264658a89" +content-hash = "bd3b2b2a3ab95481b04d72980ab5365028e6aee69b12e395b0c4cbdfde95c452" lock-version = "1.0" python-versions = "^3.8" @@ -882,6 +890,10 @@ idna = [ {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, ] +itsdangerous = [ + {file = "itsdangerous-1.1.0-py2.py3-none-any.whl", hash = "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"}, + {file = "itsdangerous-1.1.0.tar.gz", hash = "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19"}, +] multidict = [ {file = "multidict-4.7.6-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:275ca32383bc5d1894b6975bb4ca6a7ff16ab76fa622967625baeebcf8079000"}, {file = "multidict-4.7.6-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:1ece5a3369835c20ed57adadc663400b5525904e53bae59ec854a5d36b39b21a"}, diff --git a/pyproject.toml b/pyproject.toml index d7de0b5a..f90a6ed8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ steam = "*" sqlalchemy = "^1.3.18" bcrypt = "^3.1.7" + itsdangerous = "^1.1.0" [tool.poetry.dependencies.royalnet] version = "~5.10.4" From 0d1757f4c86ba4e0ad841692edbdba0759d9b9b6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 16:11:08 +0200 Subject: [PATCH 13/15] Fix royalpackversion.py not printing the version --- royalpack/commands/royalpackversion.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/royalpack/commands/royalpackversion.py b/royalpack/commands/royalpackversion.py index f2b17584..5795e287 100644 --- a/royalpack/commands/royalpackversion.py +++ b/royalpack/commands/royalpackversion.py @@ -1,5 +1,6 @@ from typing import * +import functools import pkg_resources import royalnet.commands as rc @@ -12,14 +13,16 @@ class RoyalpackCommand(rc.Command): syntax: str = "" @property - def royalpack_version(self): + @functools.lru_cache(1) + def royalpack_version(self) -> str: return pkg_resources.get_distribution("royalpack").version async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: + # noinspection PyUnreachableCode if __debug__: message = f"ℹ️ Royalpack [url=https://github.com/Steffo99/royalpack/]Unreleased[/url]\n" else: message = f"ℹ️ Royalpack [url=https://github.com/Steffo99/royalpack/releases/tag/{self.royalpack_version}]{self.royalpack_version}[/url]\n" - if "69" in semantic: + if "69" in self.royalpack_version: message += "(Nice.)" await data.reply(message) From ae3f88cc7253a29c5fca87113ec88bd84de9c292 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 16:16:18 +0200 Subject: [PATCH 14/15] Prevent duplicate mmresponses from being inserted --- royalpack/utils/mmtask.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/royalpack/utils/mmtask.py b/royalpack/utils/mmtask.py index 0d0f3cbc..3c92f076 100644 --- a/royalpack/utils/mmtask.py +++ b/royalpack/utils/mmtask.py @@ -5,6 +5,7 @@ import logging import datetime import enum import asyncio as aio +import psycopg2 from telegram import InlineKeyboardMarkup as InKM from telegram import InlineKeyboardButton as InKB @@ -179,7 +180,10 @@ class MMTask: else: # Change their response mmresponse.choice = choice - await data.session_commit() + try: + await data.session_commit() + except psycopg2.Error: + raise rc.UserError("Hai già risposto nello stesso modo a questo matchmaking.") await self.telegram_channel_message_update() From 38a689ccf0d233bc93a01c1fa15eb68ebaf37194 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 16:17:28 +0200 Subject: [PATCH 15/15] Fix invalid list comprehension --- royalpack/commands/dog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/royalpack/commands/dog.py b/royalpack/commands/dog.py index 2179925e..d4ac318f 100644 --- a/royalpack/commands/dog.py +++ b/royalpack/commands/dog.py @@ -159,7 +159,7 @@ class DogCommand(rc.Command): breed = args.joined() if breed: if breed == "list": - await data.reply("\n".join(["ℹ️ Razze disponibili:", [f"[c]{breed}[/c]" for breed in self._breeds]])) + await data.reply("\n".join(["ℹ️ Razze disponibili:", *[f"[c]{breed}[/c]" for breed in self._breeds]])) if breed in self._breeds: url = f"https://dog.ceo/api/breed/{breed}/images/random" else: