diff --git a/README.md b/README.md index 2186ef24..62549289 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ### 2022/9/3 * 原神玩家查询增加须弥地区 [@pull/1053](https://github.com/HibiKier/zhenxun_bot/pull/1053) +* av号覆盖全面,且修复av号链接 [@pull/1033](https://github.com/HibiKier/zhenxun_bot/pull/1033) * 修复词条含有CQ回答的模糊匹配无法被解析 +* 禁言检测图片在内存中获取图片hash +* B站订阅在群里中任意群管理员可以统一管理(原来为管理员1无法删除管理员2的订阅) ### 2022/8/27 diff --git a/plugins/bilibili_sub/__init__.py b/plugins/bilibili_sub/__init__.py index 4ae0eeec..b43740b5 100755 --- a/plugins/bilibili_sub/__init__.py +++ b/plugins/bilibili_sub/__init__.py @@ -160,7 +160,7 @@ async def _( async def _(event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGroup()): msg = reg_group[0] id_ = ( - f"{event.user_id}:{event.group_id}" + f"{event.group_id}" if isinstance(event, GroupMessageEvent) else f"{event.user_id}" ) diff --git a/plugins/mute.py b/plugins/mute.py index c937dac6..ab39e8df 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -1,3 +1,7 @@ +from io import BytesIO + +import imagehash +from PIL import Image from nonebot import on_message, on_command from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, Message, ActionFailed from nonebot.adapters.onebot.v11.permission import GROUP @@ -70,10 +74,8 @@ def save_data(): json.dump(mute_data, f, indent=4) -async def download_img_and_hash(url, group_id) -> str: - if await AsyncHttpx.download_file(url, TEMP_PATH / f"mute_{group_id}_img.jpg"): - return str(get_img_hash(TEMP_PATH / f"mute_{group_id}_img.jpg")) - return "" +async def download_img_and_hash(url) -> str: + return str(imagehash.average_hash(Image.open(BytesIO((await AsyncHttpx.get(url)).content)))) mute_dict = {} @@ -87,7 +89,7 @@ async def _(bot: Bot, event: GroupMessageEvent): img_list = get_message_img(event.json()) img_hash = "" for img in img_list: - img_hash += await download_img_and_hash(img, event.group_id) + img_hash += await download_img_and_hash(img) msg += img_hash if not mute_data.get(group_id): mute_data[group_id] = { diff --git a/plugins/word_bank/_model.py b/plugins/word_bank/_model.py index 2e6557be..c254b0d7 100644 --- a/plugins/word_bank/_model.py +++ b/plugins/word_bank/_model.py @@ -143,7 +143,7 @@ class WordBank(db.Model): text += seg.data["text"] elif seg.type == "face": text += f"[face:placeholder_{index}]" - _list.append(seg.data.id) + _list.append(seg.data['id']) elif seg.type == "at": text += f"[at:placeholder_{index}]" _list.append(seg.data["qq"]) diff --git a/plugins/word_bank/word_handle.py b/plugins/word_bank/word_handle.py index 5d6158ed..cd499712 100644 --- a/plugins/word_bank/word_handle.py +++ b/plugins/word_bank/word_handle.py @@ -130,8 +130,6 @@ async def _( problem = temp break problem = unescape(problem) - # index = len((word_scope or "") + "添加词条" + (word_type or "") + problem) + 1 - # event.message[0] = event.message[0].data["text"][index + 1 :].strip() event.message[0] = event.message[0].data["text"].split('答', maxsplit=1)[-1].strip() state["word_scope"] = word_scope state["word_type"] = word_type diff --git a/utils/utils.py b/utils/utils.py index d235a0e4..f8229192 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -238,6 +238,25 @@ def get_message_img(data: Union[str, Message]) -> List[str]: return img_list +def get_message_face(data: Union[str, Message]) -> List[str]: + """ + 说明: + 获取消息中所有的 face Id + 参数: + :param data: event.json() + """ + face_list = [] + if isinstance(data, str): + data = json.loads(data) + for msg in data["message"]: + if msg["type"] == "face": + face_list.append(msg["data"]["id"]) + else: + for seg in data["face"]: + face_list.append(seg.data["id"]) + return face_list + + def get_message_img_file(data: Union[str, Message]) -> List[str]: """ 说明: