mirror of
https://github.com/Refound-445/nonebot-plugin-nailongremove.git
synced 2025-11-04 21:22:43 +08:00
up
This commit is contained in:
parent
d270c15556
commit
f1d5225217
@ -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` | 是否撤回消息 |
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user