From d70477ec6dd5cbaecb35089d3a7bf4dedb161e7d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 18 Jul 2020 16:29:43 +0200 Subject: [PATCH] Migrate /pug to /dog --- royalpack/commands/__init__.py | 4 ++-- royalpack/commands/{pug.py => dog.py} | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) rename royalpack/commands/{pug.py => dog.py} (64%) diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index cc63c0eb..9ce8b05e 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -43,7 +43,7 @@ from .ping import PingCommand from .play import PlayCommand from .playmode import PlaymodeCommand from .pmots import PmotsCommand -from .pug import PugCommand +from .dog import DogCommand from .queue import QueueCommand from .rage import RageCommand from .reminder import ReminderCommand @@ -110,7 +110,7 @@ available_commands = [ PlayCommand, PlaymodeCommand, PmotsCommand, - PugCommand, + DogCommand, QueueCommand, RageCommand, ReminderCommand, diff --git a/royalpack/commands/pug.py b/royalpack/commands/dog.py similarity index 64% rename from royalpack/commands/pug.py rename to royalpack/commands/dog.py index 6846212b..cd80ff52 100644 --- a/royalpack/commands/pug.py +++ b/royalpack/commands/dog.py @@ -4,18 +4,22 @@ import aiohttp import io -class PugCommand(rc.Command): - name: str = "pug" +class DogCommand(rc.Command): + name: str = "dog" - description: str = "Invia un carlino casuale in chat." + description: str = "Invia un cane della razza specificata in chat." - syntax: str = "" - - aliases = ["carlino", "carlo", "mallllco"] + syntax: str = "[razza]" async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: + breed = args.joined() + if breed: + url = f"https://dog.ceo/api/breed/{breed}/images/random" + else: + url = f"https://dog.ceo/api/breeds/image/random" + async with aiohttp.ClientSession() as session: - async with session.get("https://dog.ceo/api/breed/pug/images/random") as response: + async with session.get(url) as response: if response.status >= 400: raise rc.ExternalError(f"Request returned {response.status}") result = await response.json()