Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.3.9 instead.

nonebot_plugin_lazy

LAZY Server 官方支持的 Nonebot2 插件,让你的 QQBot 可以查询学在浙大信息。

本仓库目前 Vibe Coding 较高,在此致歉

大规模的重构正在进行中……

功能特性

  • 点名监控 — 定时拉取进行中的点名,新点名出现时即时通知
  • 待办监控 — 定时拉取待办任务,新待办出现时即时通知
  • 私聊注册 — 用户在私聊中通过 /register 命令绑定学号密码,安全声明确认后自动验证
  • 多用户支持 — 支持 .env 静态配置 + 多人私聊注册,每人独立 Token 和通知
  • 任务管理 — 通过 /task 命令查看和修改监控任务的启用状态与轮询间隔
  • @用户通知 — 群通知 @ 具体用户(数据触发者),而非 @全体成员
  • 自动重连 — Token 过期自动重新登录,服务器不可达告警

安装

方式一:pip install

直接通过 pip 安装:

pip install nonebot-plugin-lazy

开发模式下使用可编辑安装:

git clone https://github.com/yangshu233/nonebot_plugin_lazy.git
cd nonebot_plugin_lazy
pip install -e .

方式二:本地插件(开发/测试)

克隆仓库后,在 bot.py 中加载:

nonebot.load_plugins("src/plugins")

src/plugins/lazy_monitor/ 保留了一个向后兼容的 shim,会自动转发到 nonebot_plugin_lazy。

配置

在 .env(或 .env.prod)中添加以下配置:

# LAZY 服务器地址(必填)
LAZY_MONITOR__SERVER_URL=http://127.0.0.1:8765

# 可选:静态配置学号密码(不配置则等待私聊注册)
LAZY_MONITOR__STUDENTID=3xx010xxxx
LAZY_MONITOR__PASSWORD=your_password
LAZY_MONITOR__OWNER_QQ=123456789

# 轮询间隔(秒,默认30)
LAZY_MONITOR__POLL_INTERVAL=30

# 通知目标
LAZY_MONITOR__NOTIFY_GROUPS=[123456789]
LAZY_MONITOR__NOTIFY_USERS=[987654321]

# 功能开关
LAZY_MONITOR__ENABLE_ROLLCALL=true
LAZY_MONITOR__ENABLE_TODO=true

# 重试策略
LAZY_MONITOR__MAX_RETRIES=3
LAZY_MONITOR__RETRY_DELAY=5

注意:list[int] 类型的字段(NOTIFY_GROUPS 等)使用 JSON 数组格式 [123, 456]。

使用

注册

场景 命令 行为
私聊 /register 四步骤对话:安全提示→确认→学号→密码→验证→绑定
群聊 /register @用户并引导到私聊

任务管理

所有命令均需使用私聊或在群聊中 @Bot 触发。

命令 说明
/task list 列出所有监控任务及当前状态
/task enable <task_id> 启用指定任务
/task disable <task_id> 停用指定任务
/task interval <task_id> <秒> 修改指定任务的轮询间隔
/task reset <task_id> 恢复指定任务为系统默认配置

示例:

/task list
/task enable rollcall_watch
/task interval todo_watch 120
/task disable todo_watch

通知格式

点名通知:

🔔 新点名通知
————————
课程:新中国史
发起人:陈荣
类型:雷达点名

待办通知:

📋 新待办通知
————————
标题:微积分第四章作业
课程:微积分(上)
截止时间:2026-05-20 23:59

项目结构

nonebot_plugin_lazy/
├── nonebot_plugin_lazy/   ← pip/nb install 的标准包
│   ├── __init__.py        # 插件入口:启动时注册 .env 账号 + 启动定时任务
│   ├── config.py          # Pydantic 配置模型,绑定 .env 环境变量
│   ├── state.py           # 多用户会话管理(UserManager + UserSession + MonitorState)
│   ├── auth.py            # Token 管理(登录/自动注册/401 重认证)
│   ├── monitor.py         # 轮询引擎:多用户独立拉取数据 + 差异检测
│   ├── notifier.py        # 通知格式化 + OneBot 消息发送(@用户)
│   └── handler.py         # 命令处理器(/register 注册 /task 任务管理)
│
├── src/plugins/
│   └── lazy_monitor/
│       └── __init__.py    # 向后兼容 shim(转发到 nonebot_plugin_lazy)
│
├── pyproject.toml         # 构建配置 + nb plugin install 元数据
├── .env.example           # 配置模板
└── README.md              # 本文件

架构

用户 ── QQ 消息 ──→ go-cqhttp ── OneBot WS ──→ Nonebot2 Bot
                                                    │
                                            nonebot_plugin_lazy
                                                    │
                                           HTTP 轮询 (30s)
                                                    │
                                                    ▼
                                              LAZY SERVER
                                                    │
                                           HTTP 请求 学在浙大 API

依赖

  • nonebot2 >= 2.4.0
  • nonebot-adapter-onebot >= 2.4.0
  • nonebot-plugin-apscheduler
  • httpx >= 0.28.0
  • Python >= 3.12

许可证

AGPL-3.0-only

Metadata

Release files for nonebot-plugin-lazy 0.3.4

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-lazy 0.3.4
File Size Uploaded
nonebot_plugin_lazy-0.3.4.tar.gz 29.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-lazy 0.3.4
File Interpreter ABI Platform
nonebot_plugin_lazy-0.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 59.0 kB

Release files / nonebot_plugin_lazy-0.3.4.tar.gz

Download URL nonebot_plugin_lazy-0.3.4.tar.gz
Size 29.0 kB
Tags Source
SHA-256 checksum
How to use checksums
efcd1893c4aa0a11f51ae0c9ccc45c7375aa4792e0eef83e06c6c331ad7dc907
BLAKE2b-256 checksum
How to use checksums
88e98c00de0ddd99f02be3807d2435eb07f2213b9fe39cc38b81575c1b9f7530
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nonebot_plugin_lazy-0.3.4-py3-none-any.whl

Download URL nonebot_plugin_lazy-0.3.4-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b4177d07bf889614f10c99a4a2cacfe35d17dfdd5e0960e9573f86187fbeca8
BLAKE2b-256 checksum
How to use checksums
d72e82b02f3b93f6a9f8e2c477812b93684c47592df02eb8238effc16da8a438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

This release

0.3.4 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.1.0

2 release files

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