|
@@ -2,6 +2,7 @@ from logging import Logger
|
|
|
import random
|
|
|
import asyncio
|
|
|
|
|
|
+from aiohttp import FormData, MultipartWriter
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
from rollbot import as_command, RollbotFailure, Attachment
|
|
@@ -23,20 +24,22 @@ async def inspire(req: Request, logger: Logger):
|
|
|
|
|
|
@as_command
|
|
|
async def shield(req: Request, blazon: Args, logger: Logger):
|
|
|
+ boundary = f"----RollbotBoundary{''.join(str(random.randint(0, 9)) for _ in range(10))}"
|
|
|
+ headers = {
|
|
|
+ "Content-Type": f"multipart/form-data; boundary={boundary}",
|
|
|
+ "Cache-Control": "no-cache",
|
|
|
+ }
|
|
|
+ with MultipartWriter(boundary=boundary) as form:
|
|
|
+ form.append(blazon).set_content_disposition("form-data", name="blazon")
|
|
|
+ form.append("1").set_content_disposition("form-data", name="asfile")
|
|
|
+ form.append("wappenwiki").set_content_disposition("form-data", name="palette")
|
|
|
+ form.append("flat").set_content_disposition("form-data", name="effect")
|
|
|
+ form.append("500").set_content_disposition("form-data", name="size")
|
|
|
try:
|
|
|
async with req.post(
|
|
|
"https://drawshield.net/include/drawshield.php",
|
|
|
- headers={
|
|
|
- "Content-Type": "multipart/form-data; boundary=----RollbotBoundary",
|
|
|
- "Cache-Control": "no-cache",
|
|
|
- },
|
|
|
- data={
|
|
|
- "blazon": blazon,
|
|
|
- "asfile": 1,
|
|
|
- "palette": "wappenwiki",
|
|
|
- "effect": "flat",
|
|
|
- "size": 500,
|
|
|
- },
|
|
|
+ headers=headers,
|
|
|
+ data=form,
|
|
|
) as res:
|
|
|
res.raise_for_status()
|
|
|
return Attachment("image", await res.read())
|