This is an API wrapper for the idiot's guide api The wrapper is asynchronous and is highly compatible with discord.py Being built with aiohttp that comes with discord.py you don't have to add extra dependencies!
Currently its only possible to download it from github, make sure you have git installed.
pip install git+https://github.com/freetnt5852/idioticapi
Run same command with -U flag to update.
Retrieving image in a regular code
import idioticapi
import asyncio
client = idioticapi.Client("Your api key", dev=True)
async def main():
img = open("test.png", "wb")
img.write(await client.blame("This person"))
asyncio.get_event_loop().run_until_complete(main())
Discord.py rewrite example
import idioticapi
# you want easy access to it so maybe attach it to your bot # object, this allowes access to cogs as well and you don't have to remake the class everywhere.
bot.api = idioticapi.Client("Your api key", dev=True)
# or in your cog self.client = idioticapi.Client("key", dev=True)
@bot.command()
async def blame(ctx, *, text):
await ctx.send(file=discord.File(await bot.api.blame(text), "blame.png"))
# a simple example, change it to whatever you like to fit in a cog etc, also works with old d.py 0.16.x just change the way i sent things.
Discord.py async example
import idioticapi
bot.api = idioticapi.Client("Your api key", dev=True)
@bot.command(pass_context=True)
async def blame(ctx, *, text):
await bot.send_file(ctx.message.channel, await bot.api.blame(text), "blame.png")
More info:
Client takes a session as third argument, which you can reuse another session if you have one or leave it to create a new aiohttp.ClientSession()
Python Minimum version: 3.5 Dependencies:
- aiohttp
Contributing is allowed anytime just open a Pull Request with your changes.
Released under MIT License.