Skip to main content

NoneBot 广告屏蔽插件,支持AI检测和二维码识别

Project description

nonebot_plugin_adsblocker

简单、轻量的 NoneBot 插件,用于检测并阻断群聊/私聊中的广告类消息。提供可配置的匹配规则、白名单与日志通知,适合在机器人里做基础的广告拦截与记录。

功能亮点

  • 基于DeepSeek的违规消息检测
  • 支持白名单(用户 / 群 / 频道)
  • 可选的拦截通知与日志上报
  • 简单的配置项,易于扩展与二次开发

适用场景

  • 群聊中屏蔽常见广告、钓鱼链接或垃圾推送
  • 私聊中自动撤回疑似广告内容并记录
  • 作为更复杂审核系统的第一道过滤

兼容性

  • 适用于 NoneBot2

安装

从 PyPI(如有):

pip install nonebot-plugin-adsblocker

从 GitHub 仓库安装(开发/最新版):

pip install git+https://github.com/Heartestrella/nonebot_plugin_adsblocker.git

或者把仓库作为子模块/源码放入你的项目中并在运行环境中安装依赖:

git clone https://github.com/Heartestrella/nonebot_plugin_adsblocker.git
cd nonebot_plugin_adsblocker
pip install -r requirements.txt
pip install -e .

快速使用

在 NoneBot 项目中加载本插件(示例):

在启动脚本或 bot 初始化处:

import nonebot

nonebot.init()
# 方式一:通过插件名加载
nonebot.load_plugin("nonebot_plugin_adsblocker")
# 方式二:如果根据项目结构,直接指定模块路径
nonebot.load_plugins("src/plugins")  # 若插件位于此路径
app = nonebot.get_asgi()

启动后,请通过指令/set_apikey sk-xxx 配置DeepSeek API

行为示例

  • 当检测到消息匹配任一 block_patterns 时:
    • 阻止消息被机器人进一步处理(或按实现删/屏蔽/回复)
    • 记录日志(如配置了 log_target)
    • 向配置的超级管理员发送提醒信息 群内发送设置的提示词
    • image
    • image

权限与注意事项

  • 插件若需删除/撤回消息或查看群信息,需要给Bot群内管理员权限。

开发与调试

本仓库包含基本的开发流程建议:

  • 克隆仓库并安装开发依赖:
git clone https://github.com/Heartestrella/nonebot_plugin_adsblocker.git
cd nonebot_plugin_adsblocker
pip install -r dev-requirements.txt
  • 运行示例 bot(如果仓库提供了 demo):
python demo_bot.py
  • 修改规则后,可在测试群/测试账号中验证效果,观察日志并调整正则或关键字。

  • 请在提交 PR 前运行代码格式化、静态检查并补充必要测试(如有测试框架)。

贡献

欢迎提交 issue 或 PR。如果你要贡献:

  1. 先开 issue 描述你的想法或问题
  2. 基于最新主干创建分支并提交变更
  3. 提交 PR,并在 PR 描述中说明变更目的与影响范围

许可证

请参见仓库根目录的 LICENSE 文件获取准确的授权信息。

联系方式

若有问题或建议,可以通过 issue 提交,或联系仓库维护者(见 GitHub 仓库主页)。


以上为基础 README 模板。若希望我把字段名和示例配置严格对齐到仓库现有实现(例如具体的配置项名称、日志接口、管理命令等),请把仓库中的配置/代码片段发给我,我会把文档调整为精确可用的版本。

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_adsblocker-0.1.1.tar.gz (17.0 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_adsblocker-0.1.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_adsblocker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1b3a1eeea352bd54d834ee7f654c2d73d97cff36e524b7d2a9f5a560677b9694
MD5 6f5253e187c842d5b4ccbb60bd45d4c4
BLAKE2b-256 cbbb4e5b60b5896a2681b1bd77450b9884110dd1575f9757fc18e687e77aedef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_adsblocker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ddc9d626b39da6f712cba673c486274a068a7021910a76e58bf270c819b8b3a
MD5 b521a5d04fa35747e45994ea0731f899
BLAKE2b-256 7bc561d94c147f779d61d48cd450aa3eb1de96f1c9e37af3d736891090ba63aa

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