From 3fe7e9483430f458f76a0d8aea1aabadc417fef1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 6 Jun 2020 02:16:52 +0200 Subject: [PATCH] publish: 5.8.14 --- poetry.lock | 6 +++--- pyproject.toml | 2 +- royalpack/commands/__init__.py | 2 ++ royalpack/commands/cat.py | 28 ++++++++++++++++++++++++++++ royalpack/version.py | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 royalpack/commands/cat.py diff --git a/poetry.lock b/poetry.lock index b17b44f0..23f7ebe0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -709,7 +709,7 @@ description = "YouTube video downloader" name = "youtube-dl" optional = false python-versions = "*" -version = "2020.5.29" +version = "2020.6.6" [metadata] content-hash = "9245b7ae163a3746554cd31e3b20294d26aa3534cc78303a419ac54850db55cb" @@ -1181,6 +1181,6 @@ yarl = [ {file = "yarl-1.4.2.tar.gz", hash = "sha256:58cd9c469eced558cd81aa3f484b2924e8897049e06889e8ff2510435b7ef74b"}, ] youtube-dl = [ - {file = "youtube_dl-2020.5.29-py2.py3-none-any.whl", hash = "sha256:2d45840772ecc57e151b0be78dd89e9772b6aa29295746be38abb9c30dad5bb3"}, - {file = "youtube_dl-2020.5.29.tar.gz", hash = "sha256:1a3d84afa851dce2fccc2dfc0f9ffa0e22314ffba6d528b34b4a7fe3e0cf2264"}, + {file = "youtube_dl-2020.6.6-py2.py3-none-any.whl", hash = "sha256:813310fb7ab265c379e9aebb2bd6cde6995f9a8f22a06d2ff81c05dfab7da864"}, + {file = "youtube_dl-2020.6.6.tar.gz", hash = "sha256:74e6cc7395060fc39f0b8e21c1e4707486da904c96145bd875187bda2da83b04"}, ] diff --git a/pyproject.toml b/pyproject.toml index 49b4e350..73e6dbcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [tool.poetry] name = "royalpack" - version = "5.8.13" + version = "5.8.14" description = "A Royalnet command pack for the Royal Games community" authors = ["Stefano Pigozzi "] license = "AGPL-3.0+" diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index 48ce16ed..fecb9e04 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -60,6 +60,7 @@ from .pug import PugCommand from .magicktreasure import MagicktreasureCommand from .treasure import TreasureCommand from .givetreasure import GivetreasureCommand +from .cat import CatCommand # Enter the commands of your Pack here! available_commands = [ @@ -124,6 +125,7 @@ available_commands = [ MagicktreasureCommand, TreasureCommand, GivetreasureCommand, + CatCommand, ] # Don't change this, it should automatically generate __all__ diff --git a/royalpack/commands/cat.py b/royalpack/commands/cat.py new file mode 100644 index 00000000..fa45344a --- /dev/null +++ b/royalpack/commands/cat.py @@ -0,0 +1,28 @@ +from typing import * +import royalnet.commands as rc +import aiohttp +import io + + +class CatCommand(rc.Command): + name: str = "cat" + + description: str = "Invia un gatto casuale in chat." + + syntax: str = "" + + aliases = ["catto", "kat", "kitty", "kitten", "gatto", "miao", "garf", "basta"] + + async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: + async with aiohttp.ClientSession() as session: + async with session.get("https://api.thecatapi.com/v1/images/search") as response: + if response.status >= 400: + raise rc.ExternalError(f"Request returned {response.status}") + result = await response.json() + assert len(result) == 1 + cat = result[0] + assert "url" in cat + url = cat["url"] + async with session.get(url) as response: + img = await response.content.read() + await data.reply_image(image=io.BytesIO(img)) diff --git a/royalpack/version.py b/royalpack/version.py index 4deca9eb..e6b5c2aa 100644 --- a/royalpack/version.py +++ b/royalpack/version.py @@ -1 +1 @@ -semantic = "5.8.13" +semantic = "5.8.14"