fix: use aiohttp for racoon command
Build and publish ich_iel bot / build (push) Successful in 1m29s
Build and publish ich_iel bot / build (push) Successful in 1m29s
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import aiohttp
|
||||||
import fluxer
|
import fluxer
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
@@ -166,17 +167,12 @@ async def racoon(message):
|
|||||||
"https://api.mapach.es/v1/meme",
|
"https://api.mapach.es/v1/meme",
|
||||||
"https://api.mapach.es/v1/coon"
|
"https://api.mapach.es/v1/coon"
|
||||||
])
|
])
|
||||||
response = requests.get(urls)
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(urls) as response:
|
||||||
|
image_bytes = await response.read()
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
await message.channel.send("Failed to fetch racoon image")
|
await message.channel.send("Failed to fetch racoon image")
|
||||||
return
|
return
|
||||||
_, _, payload = response.text.strip().partition(",")
|
|
||||||
try:
|
|
||||||
image_bytes = base64.b64decode(payload)
|
|
||||||
except (ValueError, base64.binascii.Error):
|
|
||||||
await message.channel.send("Could not decode racoon image")
|
|
||||||
logging.warning(f"Failed to decode base64 image data: {payload}")
|
|
||||||
return
|
|
||||||
await message.channel.send(file=fluxer.File(image_bytes, filename="racoon.jpg"))
|
await message.channel.send(file=fluxer.File(image_bytes, filename="racoon.jpg"))
|
||||||
|
|
||||||
async def post_reddit():
|
async def post_reddit():
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
fluxer.py
|
fluxer.py
|
||||||
requests
|
requests
|
||||||
asyncio
|
asyncio
|
||||||
dotenv
|
dotenv
|
||||||
|
aiohttp
|
||||||
Reference in New Issue
Block a user