B站订阅在群里中任意群管理员可以统一管理

This commit is contained in:
HibiKier 2022-09-03 17:30:03 +08:00
parent 1d141c9313
commit 1138a115ce
6 changed files with 31 additions and 9 deletions

View File

@ -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

View File

@ -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}"
)

View File

@ -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] = {

View File

@ -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"])

View File

@ -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

View File

@ -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]:
"""
说明: