diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..ca97a148 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,20 @@ +name: Syntax check + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - 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 all .py files + run: python -m compileall royalpack diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..17496f3e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,20 @@ +name: Publish to PyPI + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + - 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: publish --build 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: diff --git a/royalpack/commands/fortune.py b/royalpack/commands/fortune.py index d662a1b8..b4555aaa 100644 --- a/royalpack/commands/fortune.py +++ b/royalpack/commands/fortune.py @@ -33,12 +33,20 @@ 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!", + "🧨 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: diff --git a/royalpack/commands/royalpackversion.py b/royalpack/commands/royalpackversion.py index a9ef4f27..702e2f5e 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,7 +13,8 @@ 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: 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()