mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
复读修改回图片下载
This commit is contained in:
parent
5ef0ce5aa8
commit
109c645e68
@ -293,6 +293,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
|||||||
|
|
||||||
## 更新
|
## 更新
|
||||||
|
|
||||||
|
### 2022/10/23
|
||||||
|
|
||||||
|
* 复读修改回图片下载
|
||||||
|
|
||||||
### 2022/10/22
|
### 2022/10/22
|
||||||
|
|
||||||
* 更新依赖注入
|
* 更新依赖注入
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
from io import BytesIO
|
from utils.image_utils import get_img_hash
|
||||||
import imagehash
|
|
||||||
from PIL import Image
|
|
||||||
from nonebot.adapters.onebot.v11.permission import GROUP
|
from nonebot.adapters.onebot.v11.permission import GROUP
|
||||||
from configs.path_config import TEMP_PATH
|
from configs.path_config import TEMP_PATH
|
||||||
import random
|
import random
|
||||||
@ -10,6 +8,7 @@ from utils.utils import get_message_img, get_message_text
|
|||||||
from nonebot.adapters.onebot.v11 import GroupMessageEvent
|
from nonebot.adapters.onebot.v11 import GroupMessageEvent
|
||||||
from configs.config import Config
|
from configs.config import Config
|
||||||
from utils.http_utils import AsyncHttpx
|
from utils.http_utils import AsyncHttpx
|
||||||
|
from services.log import logger
|
||||||
from configs.config import NICKNAME
|
from configs.config import NICKNAME
|
||||||
|
|
||||||
|
|
||||||
@ -124,5 +123,15 @@ async def _(event: GroupMessageEvent):
|
|||||||
await fudu.finish("[[_task|fudu]]" + rst)
|
await fudu.finish("[[_task|fudu]]" + rst)
|
||||||
|
|
||||||
|
|
||||||
async def get_fudu_img_hash(url):
|
async def get_fudu_img_hash(url, group_id):
|
||||||
return str(imagehash.average_hash(Image.open(BytesIO((await AsyncHttpx.get(url)).content))))
|
try:
|
||||||
|
if await AsyncHttpx.download_file(
|
||||||
|
url, TEMP_PATH / f"compare_{group_id}_img.jpg"
|
||||||
|
):
|
||||||
|
img_hash = get_img_hash(TEMP_PATH / f"compare_{group_id}_img.jpg")
|
||||||
|
return str(img_hash)
|
||||||
|
else:
|
||||||
|
logger.warning(f"复读下载图片失败...")
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"复读读取图片Hash出错 {type(e)}:{e}")
|
||||||
|
return ""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user