Skip to main content

一个用于拦截 Bot 发送包含敏感词或正则匹配内容的消息审查插件

Project description

nonebot-plugin-word-censor

✨ 基于 NoneBot2 的词汇与正则消息审查拦截插件 ✨

license pypi python

📖 介绍

nonebot-plugin-word-censor 是一个用于审查 NoneBot2 机器人发送内容的插件。

它可以防止机器人因为意外触发某些关键词或匹配到特定正则表达式而发送不当消息。支持通过指令实时动态管理黑名单,并具备自动通知管理员(Superuser)的功能。

核心特性:

  • 🛡️ 双重拦截:同时支持“关键词”与“正则表达式”过滤。
  • 动态管理:无需重启,通过指令即刻添加/删除规则。
  • 🔔 实时告警:拦截生效时,自动私聊通知超级用户并告知拦截原因。
  • 🔒 安全脱敏:查看列表时自动隐藏敏感词关键部分。

💿 安装

使用 nb-cli 安装(推荐)
nb plugin install nonebot-plugin-word-censor
使用 pip 安装
pip install nonebot-plugin-word-censor

⚙️ 配置

在 NoneBot2 项目的 .env 文件中添加以下配置(可选):

配置项 类型 默认值 说明
send_word_blacklist_file string ./src/send_word_blacklist.json 黑名单数据存储路径 (JSON)
send_word_priority int 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

nonebot_plugin_word_censor-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_word_censor-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_word_censor-0.1.1.tar.gz.

File metadata

  • Download URL: nonebot_plugin_word_censor-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11

File hashes

Hashes for nonebot_plugin_word_censor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4de2a65d71d0e430b5a37218ebe0cb9660de57e0b11863f087b36c47efadca1b
MD5 70d85247ee9789f7fc35a8f2b4e25f11
BLAKE2b-256 33dc88466b1eed8795319b502074eb47d7f4be84ac03d1843ebb9348ba08ff8c

See more details on using hashes here.

File details

Details for the file nonebot_plugin_word_censor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_word_censor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d6f8e36da9bf0e38f439425ec29fce4a47358f6b69e8eb09fa6385e69656b83
MD5 067a233540a5cbea2622a8e2425a9a81
BLAKE2b-256 3f915cdf9c21d040c985e94b7f5d14139e4cde9e8c85913d613e47913498a2a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page