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
+1 -1
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}"
)
+7 -5
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] = {
+1 -1
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"])
-2
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