Skip to main content
logo

NoneBot-Plugin-NoSpam

✨ NoneBot2 群刷屏防护插件 ✨

python nonebot2 uv license

📖 介绍

nonebot-plugin-nospam 是一款(ps:依托alconna,理论上其他平台也能支持)全自动、高智能的防刷屏 NoneBot2 插件。

插件在滑动时间窗口内,通过文本模糊匹配和图像感知哈希识别刷屏行为,可以识别“相似图片/文本”等刷屏方式。检测到刷屏后,插件会自动撤回刷屏消息并进行禁言处理(如果配置)。且使用计数方式统计刷屏,例如设定刷屏阈值为4条,某用户依次发送“1”“1”“2”“1”“1”五条消息,则插件会精确撤回四个“1”,不撤回“2”。

🚀 核心特性

  • 🧩 适配器兼容:消息解析与撤回基于 nonebot-plugin-alconna uniseg,理论上兼容alconna支持的所有适配器。
  • 🧠 智能文本检测:通过文本结构归一化和 Levenshtein 模糊算法相似度计算,防范形变与掺杂无意义字符的文字刷屏。
  • 👁️ 视觉查重检测:通过图像感知计算,提取得出平均哈希、差异哈希、图像边缘与区域签名,识别出经过压缩或尺寸变化后的重复图片同时,防止大体结构相同但内容不同的图片被拦截。
  • 👉 互动事件拦截:支持“群戳一戳”等触发事件的连续刷屏拦截。
  • ⚡ 全自动惩罚措施:自由配置滑动窗口期触发阈值,自动禁言成员并批量撤回窗口期内的相关联刷屏消息。
  • 🛡️ 动态权限感知:无需重启!机器人在群内被提为管理员或降级时,插件能动态感知自身权限状态,决定接管还是挂起对应群的检测任务,避免产生不必要的 API 调用,降低风控风险。

📥 安装配置

安装方式

使用 nb-cli 安装

nb plugin install nonebot-plugin-nospam

使用 pip 安装

pip install nonebot-plugin-nospam

如果使用 pip 安装,请记得在 NoneBot 项目的 pyproject.toml 或 bot.py(真的还有人在用这玩意吗?) 中手动加载插件。

⚙️ 环境配置

在项目的 .env.* 配置文件中按需添加配置:

配置项 类型 默认值 描述
nospam_list_mode string "whitelist" 过滤策略,可选 "whitelist" (白名单) 或 "blacklist" (黑名单)。
nospam_groups set[int] [] 设置白名单或黑名单涉及的群号列表。如 [12345678, 87654321]
nospam_window_seconds int 15 滑动检测窗口时长(单位:秒)。即统计这 N 秒内同一个人发送的消息。
nospam_threshold int 4 刷屏触发阈值限制(最小为2)。当在同一窗口期内相似消息条数达到此值时执行处罚。
nospam_similarity_threshold float 0.9 文本模糊匹配的重合度相似度阈值(范围 0.0 ~ 1.0)。
nospam_mute_duration int 600 命中刷屏后自动禁言时长(单位:秒)。如果设为 0 则仅撤回刷屏内容而不禁言。
nospam_ignore_self bool true 是否忽略机器人自身发出的消息和各类事件。

配置文件示例:

nospam_list_mode="whitelist"
nospam_groups='["111111111", "222222222"]'
nospam_window_seconds=15
nospam_threshold=4
nospam_similarity_threshold=0.85
nospam_mute_duration=600
nospam_ignore_self=true

🎮 使用方法

没有任何触发指令

只需在配置中添加(白名单模式)或避免排除群组(黑名单模式),并确保机器人在对应群内拥有 管理员 或 群主 权限。

📄 许可协议

本项目使用 MIT 许可证开源。

Metadata

Release files for nonebot-plugin-nospam 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-nospam 0.2.1
File Size Uploaded Provenance Actions
nonebot_plugin_nospam-0.2.1.tar.gz 17.1 kB Without provenance Details for nonebot_plugin_nospam-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-nospam 0.2.1
File Interpreter ABI Platform Actions
nonebot_plugin_nospam-0.2.1-py3-none-any.whl Python 3 none any Details for nonebot_plugin_nospam-0.2.1-py3-none-any.whl

Total release size: 36.5 kB

Release files / nonebot_plugin_nospam-0.2.1.tar.gz

Download URL nonebot_plugin_nospam-0.2.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a3fd101f3641e520419bacbdedffc764755a7526f4441c1cd63af1f4750879e2
BLAKE2b-256 checksum
How to use checksums
9639853df490aa667524bf9f1a64648ffb19ddecc1d795ce321d17cc2346bcbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / nonebot_plugin_nospam-0.2.1-py3-none-any.whl

Download URL nonebot_plugin_nospam-0.2.1-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9394c464071fa2e751ecd220727ad397d068e7450609b494ed7a226b7eb2704e
BLAKE2b-256 checksum
How to use checksums
e4abf8070f81ac8b43ac9398abea242ea7fb1e035cb25620287e682ea53b7d2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for nonebot-plugin-nospam 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page