mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-07 20:33:01 +08:00
完善tag的处理逻辑
This commit is contained in:
parent
f486d0b983
commit
8a4a7ad26c
@ -127,13 +127,26 @@ class Platform(metaclass=RegistryABCMeta, base=True):
|
|||||||
subscribed_tags: list[Tag],
|
subscribed_tags: list[Tag],
|
||||||
banned_tags: list[Tag],
|
banned_tags: list[Tag],
|
||||||
) -> bool:
|
) -> bool:
|
||||||
for tag in post_tags or []:
|
"""只要存在任意屏蔽tag则返回真,此行为优先级最高。
|
||||||
if banned_tags and tag in banned_tags:
|
存在任意被订阅tag则返回假,此行为优先级次之。
|
||||||
return True
|
若被订阅tag为空,则返回假。
|
||||||
elif subscribed_tags and tag not in subscribed_tags:
|
"""
|
||||||
return True
|
# 存在任意需要屏蔽的tag则为真
|
||||||
|
if banned_tags:
|
||||||
|
for tag in post_tags or []:
|
||||||
|
if tag in banned_tags:
|
||||||
|
return True
|
||||||
|
# 检测屏蔽tag后检测订阅tag
|
||||||
|
# 存在任意需要订阅的tag则为假
|
||||||
|
ban_it = True
|
||||||
|
if subscribed_tags:
|
||||||
|
for tag in post_tags or []:
|
||||||
|
if tag in subscribed_tags:
|
||||||
|
ban_it = False
|
||||||
|
else:
|
||||||
|
ban_it = False
|
||||||
|
|
||||||
return False
|
return ban_it
|
||||||
|
|
||||||
async def filter_user_custom(
|
async def filter_user_custom(
|
||||||
self, raw_post_list: list[RawPost], cats: list[Category], tags: list[Tag]
|
self, raw_post_list: list[RawPost], cats: list[Category], tags: list[Tag]
|
||||||
@ -145,8 +158,9 @@ class Platform(metaclass=RegistryABCMeta, base=True):
|
|||||||
if cats and cat not in cats:
|
if cats and cat not in cats:
|
||||||
continue
|
continue
|
||||||
if self.enable_tag and tags:
|
if self.enable_tag and tags:
|
||||||
post_tags = self.get_tags(raw_post)
|
if self.is_banned_post(
|
||||||
if self.is_banned_post(post_tags, **self.tag_separator(tags)):
|
self.get_tags(raw_post), *self.tag_separator(tags)
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
res.append(raw_post)
|
res.append(raw_post)
|
||||||
return res
|
return res
|
||||||
|
Loading…
x
Reference in New Issue
Block a user