mirror of
https://git.wownero.com/dsc/craiyon-irc.git
synced 2024-08-15 01:03:24 +00:00
add xmr.pm upload
This commit is contained in:
parent
e6d773f70a
commit
7b12c98b07
1 changed files with 19 additions and 1 deletions
20
main.py
20
main.py
|
@ -85,6 +85,24 @@ class Task:
|
|||
bg.paste(img, (x_start + x_offset, y_start + y_offset))
|
||||
return bg
|
||||
|
||||
async def post_image_xmr(self, image) -> str:
|
||||
url = 'https://dumb.ai.xmr.pm/paste/img'
|
||||
timeout = aiohttp.ClientTimeout(total=10)
|
||||
|
||||
data = aiohttp.FormData()
|
||||
data.add_field('files[]', image, filename='lol.jpg', content_type='image/jpg')
|
||||
|
||||
try:
|
||||
async with aiohttp.ClientSession(
|
||||
timeout=timeout,
|
||||
headers={"User-Agent": "w0w"}) as session:
|
||||
async with session.post(url, data=data) as resp:
|
||||
blob = await resp.json()
|
||||
return f"https://dumb.ai.xmr.pm{blob['redirect']}"
|
||||
|
||||
except Exception as ex:
|
||||
raise Exception("Could not upload file to xmr.pm :((")
|
||||
|
||||
async def post_image_lewd(self, image) -> str:
|
||||
timeout = aiohttp.ClientTimeout(total=5)
|
||||
|
||||
|
@ -273,7 +291,7 @@ async def main():
|
|||
image_bytes.seek(0)
|
||||
|
||||
try:
|
||||
url = await task.post_image_lewd(image_bytes)
|
||||
url = await task.post_image_xmr(image_bytes)
|
||||
except Exception as ex:
|
||||
_err(task, err=f"image upload: {ex}")
|
||||
_lower_author_task_count(task.author)
|
||||
|
|
Loading…
Reference in a new issue