fix: fix other errors

This commit is contained in:
冰苷晶
2025-03-24 13:20:05 +08:00
parent ddf54c9cf8
commit 6b0f044198
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -1,5 +1,6 @@
import re
import aiohttp
import ssl, certifi
from io import BytesIO
from . import RenderStrategy
@@ -91,7 +92,9 @@ class LocalRenderStrategy(RenderStrategy):
try:
image_url = re.findall(IMAGE_REGEX, line)[0]
print(image_url)
async with aiohttp.ClientSession(trust_env=True) as session:
ssl_context = ssl.create_default_context(cafile=certifi.where())
connector = aiohttp.TCPConnector(ssl=ssl_context)
async with aiohttp.ClientSession(trust_env=True, connector=connector) as session:
async with session.get(image_url) as resp:
image_res = Image.open(BytesIO(await resp.read()))
images[i] = image_res
+4 -1
View File
@@ -1,5 +1,6 @@
import aiohttp
import os
import ssl, certifi
from . import RenderStrategy
from astrbot.core.config import VERSION
@@ -46,7 +47,9 @@ class NetworkRenderStrategy(RenderStrategy):
},
}
if return_url:
async with aiohttp.ClientSession(trust_env=True) as session:
ssl_context = ssl.create_default_context(cafile=certifi.where())
connector = aiohttp.TCPConnector(ssl=ssl_context)
async with aiohttp.ClientSession(trust_env=True, connector=connector) as session:
async with session.post(
f"{self.BASE_RENDER_URL}/generate", json=post_data
) as resp: