一个用于拦截 Bot 发送包含敏感词或正则匹配内容的消息审查插件
Project description
📖 介绍
nonebot-plugin-word-censor 是一个用于审查 NoneBot2 机器人发送内容的插件。
它可以防止机器人因为意外触发某些关键词或匹配到特定正则表达式而发送不当消息。支持通过指令实时动态管理黑名单的功能。
💿 安装
使用 nb-cli 安装(推荐)
nb plugin install nonebot-plugin-word-censor
使用 pip 安装
pip install nonebot-plugin-word-censor
⚙️ 配置
在 NoneBot2 项目的 .env 文件中添加以下配置(可选):
SUPERUSERS = ["2428451170"] # 管理员
SEND_WORD_PRIORITY = 100 # 优先级,没啥用
🎮 使用方法
⚠️ 注意:以下指令仅 SUPERUSER (超级用户) 可用。
1. 基础指令 (普通词汇)
| 指令 | 格式 | 说明 |
|---|---|---|
| 添加词汇 | word blacklist add <内容> |
将指定内容加入黑名单 |
| 删除词汇 | word blacklist del <内容> |
将指定内容移出黑名单 |
2. 高级指令 (正则表达式)
支持 Python re 模块的语法。
| 指令 | 格式 | 示例 |
|---|---|---|
| 添加正则 | word blacklist add regex <表达式> |
... add regex \d{11} (拦截手机号) |
| 删除正则 | word blacklist del regex <表达式> |
... del regex \d{11} |
3. 其他指令
- 查看列表:
word blacklist list- 查看当前生效的所有规则(普通词汇会脱敏显示)。
- 刷新配置:
word blacklist refresh- 如果你手动修改了 JSON 文件,可使用此指令热重载。
- 帮助:
word blacklist help
本项目使用 MIT 许可证 开源
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_word_censor-0.2.1.tar.gz.
File metadata
- Download URL: nonebot_plugin_word_censor-0.2.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0436c078278b28350b3d9bf1310e804e4cf92ae0d32795b952e35b3e1a79fc19
|
|
| MD5 |
8b37eebe4e4e3e65b36f86c3f0581069
|
|
| BLAKE2b-256 |
a7ed66e73212ad880dd6172dfe0c1e4fbad924b78b8a2f5286d0a4f712d76d5f
|
File details
Details for the file nonebot_plugin_word_censor-0.2.1-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_word_censor-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18555345dd05da0c58e6d38198b53128696bb7848afe28ecc0a8e6c942cbe832
|
|
| MD5 |
6207524ced66c47ad6f826d9bafb2430
|
|
| BLAKE2b-256 |
82d141914c6c59a9a90862d349e13fe4268980eb2f42bd0e5e8f546d2f2373eb
|