This commit is contained in:
student_2333 2024-11-06 16:23:13 +08:00
parent d270c15556
commit f1d5225217
No known key found for this signature in database
GPG Key ID: 665F083BEC56F2A6
4 changed files with 15 additions and 13 deletions

View File

@ -139,6 +139,7 @@ plugins = [
| `NAILONG_NEED_ADMIN` | 否 | `False` | 当自身不为群组管理员时是否不检查群内所有图片 |
| `NAILONG_LIST_SCENES` | 否 | `[]` | 聊天场景 ID 黑白名单列表<br />在单级聊天下为该聊天 ID如 QQ 群号;<br />在多级聊天下为以 `_` 分割的各级聊天 ID如频道下的子频道或频道下私聊 |
| `NAILONG_BLACKLIST` | 否 | `True` | 是否使用黑名单模式 |
| `NAILONG_USER_BLACKLIST` | 否 | `[]` | 用户 ID 黑名单列表 |
| `NAILONG_PRIORITY` | 否 | `100` | Matcher 优先级 |
| **行为配置** | | | |
| `NAILONG_RECALL` | 否 | `True` | 是否撤回消息 |

View File

@ -304,4 +304,4 @@ nb plugin update nonebot-plugin-nailongremove
### 常见问题
常见问题请跳转至[issues](https://github.com/Refound-445/nonebot-plugin-nailongremove/issues?q=is%3Aissue+is%3Aclosed)
常见问题请跳转至 [issues](https://github.com/Refound-445/nonebot-plugin-nailongremove/issues?q=is%3Aissue+is%3Aclosed)

View File

@ -35,6 +35,7 @@ class Config(BaseModel):
nailong_need_admin: bool = False
nailong_list_scenes: List[str] = Field(default_factory=list)
nailong_blacklist: bool = True
nailong_user_blacklist: List[str] = Field(default_factory=list)
nailong_priority: int = 100
nailong_recall: bool = True

View File

@ -4,13 +4,11 @@ from nonebot import logger, on_message
from nonebot.adapters import Bot as BaseBot, Event as BaseEvent
from nonebot.permission import SUPERUSER
from nonebot.rule import Rule
from nonebot_plugin_alconna.builtins.uniseg.market_face import MarketFace
from nonebot_plugin_alconna.uniseg import Image, UniMessage, UniMsg
from nonebot_plugin_alconna.uniseg import UniMessage, UniMsg
from nonebot_plugin_uninfo import QryItrface, Uninfo
from nonebot_plugin_nailongremove.frame_source import iter_sources_in_message
from .config import DEFAULT_LABEL, config
from .frame_source import iter_sources_in_message, source_extractors
from .model import check
from .uniapi import mute, recall
@ -46,6 +44,14 @@ async def nailong_rule(
return (
# check if it's a group chat
bool(session.member) # this prop only exists in group chats
# user blacklist
and (session.user.id not in config.nailong_user_blacklist)
# scene blacklist or whitelist
and judge_list(
config.nailong_list_scenes,
session.scene_path,
config.nailong_blacklist,
)
# bypass superuser
and ((not config.nailong_bypass_superuser) or (not await SUPERUSER(bot, event)))
# bypass group admin
@ -53,14 +59,8 @@ async def nailong_rule(
(not config.nailong_bypass_admin)
or ((not session.member.role) or session.member.role.level <= 1)
)
# msg has image
and ((Image in msg) or (MarketFace in msg))
# blacklist or whitelist
and judge_list(
config.nailong_list_scenes,
session.scene_path,
config.nailong_blacklist,
)
# msg has supported seg
and (any(True for x in msg if type(x) in source_extractors))
# self is admin
and (
(not config.nailong_need_admin)