Skip to main content

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

Project description

nonebot

nonebot-plugin-word-censor

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

license pypi python

📖 介绍

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

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

💿 安装

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

⚙️ 配置

插件使用 nonebot-plugin-localstore 管理数据文件。 文件存储位置会根据操作系统不同而变化,您可以通过以下方式查看:

  1. 查看插件启动日志。
  2. 发送指令 word blacklist list 查看当前文件路径。

在 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

nonebot_plugin_word_censor-0.3.1.tar.gz (6.6 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.3.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_plugin_word_censor-0.3.1.tar.gz
  • Upload date:
  • Size: 6.6 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.3.1.tar.gz
Algorithm Hash digest
SHA256 aa2e54889d766a4ee6a8a3355cd3499f380e014cecfbb6e60d1c1e3d365531b8
MD5 f61ab16ffa9c980f89814884f091174b
BLAKE2b-256 02b87c3c2d9086c3bb5b0358c8d373ec572b921adf3df63e4d8c6d7f1b33655f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_word_censor-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5836ae24249f5ba71c93d82ca08c925266d72c45855574fa2da1eeab3442ce72
MD5 a34bd572ab3b8aaf5636f4daa54fa342
BLAKE2b-256 c925fe7c595e66d0b63ad38ad001bf0e1a6a39f120c0762afa5efd8fefa20e98

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