diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..36e361aa Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/Pipfile b/Pipfile old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/bot/__init__.py b/bot/__init__.py old mode 100644 new mode 100755 diff --git a/bot/cogs/__init__.py b/bot/cogs/__init__.py old mode 100644 new mode 100755 diff --git a/bot/cogs/logging.py b/bot/cogs/logging.py old mode 100644 new mode 100755 diff --git a/bot/cogs/security.py b/bot/cogs/security.py old mode 100644 new mode 100755 diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py old mode 100644 new mode 100755 index c9ed8042..ec15e9f0 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -1,11 +1,10 @@ -# coding=utf-8 import logging from typing import Any, Dict from discord.ext.commands import AutoShardedBot, Context, command log = logging.getLogger(__name__) - +import discord class Snakes: """ @@ -18,29 +17,35 @@ def __init__(self, bot: AutoShardedBot): async def get_snek(self, name: str = None) -> Dict[str, Any]: """ Go online and fetch information about a snake - The information includes the name of the snake, a picture of the snake, and various other pieces of info. What information you get for the snake is up to you. Be creative! - If "python" is given as the snake name, you should return information about the programming language, but with all the information you'd provide for a real snake. Try to have some fun with this! - :param name: Optional, the name of the snake to get information for - omit for a random snake :return: A dict containing information on a snake + """ + @command() - async def get(self, ctx: Context, name: str = None): + async def get(self, ctx: Context, *, query: str = None): """ Go online and fetch information about a snake - This should make use of your `get_snek` method, using it to get information about a snake. This information should be sent back to Discord in an embed. - :param ctx: Context object passed from discord.py :param name: Optional, the name of the snake to get information for - omit for a random snake """ + em = discord.Embed(title=str(query)) + em.set_footer(text='Powered by wikipedia.org') + async with self.bot.http_session.get(f"https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles={query}") as resp: + data = await resp.json() + data = data['query'] + em.description = (data["pages"][list(data["pages"].keys())[0]]["extract"])[:2000] + await ctx.send(embed=em) + + # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! diff --git a/bot/constants.py b/bot/constants.py old mode 100644 new mode 100755 diff --git a/bot/decorators.py b/bot/decorators.py old mode 100644 new mode 100755 diff --git a/bot/formatter.py b/bot/formatter.py old mode 100644 new mode 100755 diff --git a/bot/pagination.py b/bot/pagination.py old mode 100644 new mode 100755 diff --git a/bot/utils.py b/bot/utils.py old mode 100644 new mode 100755 diff --git a/doc/README.md b/doc/README.md old mode 100644 new mode 100755 diff --git a/doc/bot-setup.md b/doc/bot-setup.md old mode 100644 new mode 100755 diff --git a/doc/linting.md b/doc/linting.md old mode 100644 new mode 100755 diff --git a/doc/pipenv.md b/doc/pipenv.md old mode 100644 new mode 100755 diff --git a/run.py b/run.py old mode 100644 new mode 100755 index 2ec711fd..5d552bcd --- a/run.py +++ b/run.py @@ -35,6 +35,7 @@ # Commands, etc bot.load_extension("bot.cogs.snakes") -bot.run(os.environ.get("BOT_TOKEN")) +bot.run(os.environ.get('BOT_TOKEN')) + bot.http_session.close() # Close the aiohttp session when the bot finishes running diff --git a/tox.ini b/tox.ini old mode 100644 new mode 100755