Compare commits

..

No commits in common. "dd769ae19c233d4c25aea328784be6c4ddd50ee1" and "735f1b057d347d5ebb43c70a203c772681bc04dd" have entirely different histories.

2 changed files with 11 additions and 15 deletions

View File

@ -9,7 +9,7 @@
"requirements": [
"requests",
"pillow",
"imgkit"
"htmlwebshot"
],
"tags": [
"gaming",

View File

@ -1,16 +1,16 @@
from redbot.core import commands, Config, checks
from redbot.core import commands
import discord
import requests
import imgkit
import htmlwebshot
from PIL import Image, ImageOps
import os
UID = 0x181eff7aacab91fa4051d1d995d44050
photographer = htmlwebshot.WebShot()
def image(name, html):
open_image = imgkit.from_string(html, False)
open_image = Image.open(open_image)
photographer.create_pic(html=html, output=f"{name}.png")
open_image = Image.open(f"{name}.png")
image_box = ImageOps.invert(open_image.convert("RGB")).getbbox()
open_image.crop(image_box).save(f"{name}_cropped.png")
@ -18,16 +18,12 @@ def image(name, html):
class Sarenrae(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.conf = Config.get_conf(self, identifier=UID, force_registration=True)
default_global = {
"pf2_token": "",
}
self.conf.register_global(**default_global)
self.token = None
@commands.command()
async def ancestry(self, ctx, *args):
name = args[0]
headers = {"Authorization": self.conf.pf2_token}
headers = {"Authorization": self.token}
req = requests.get(f"https://api.pathfinder2.fr/v1/pf2/ancestry?name={name}", headers=headers).json()
html = req["results"][0]["data"]["description"]["value"]
filename = f"ancestry-{name}"
@ -36,8 +32,8 @@ class Sarenrae(commands.Cog):
os.remove(f"{filename}.png")
os.remove(f"{filename}_cropped.png")
@commands.command()
@checks.is_owner()
async def sarenrae_token(self, ctx, *args):
self.conf.pf2_token.set(args[0])
return await ctx.send(f"Set token to {self.conf.pf2_token}")
self.token = args[0]
return await ctx.send(f"Set token to {self.token}")