📖 介绍
NoneBot2 插件:监控 Bot 在线状态,检测 Bot 离线并发送邮件通知。
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebot-plugin-bot-monitor --upgrade
使用 pypi 源安装
nb plugin install nonebot-plugin-bot-monitor --upgrade -i "https://pypi.org/simple"
使用清华源安装
nb plugin install nonebot-plugin-bot-monitor --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"
使用包管理器安装
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令uv
uv add nonebot-plugin-bot-monitor
安装仓库 master 分支
uv add git+https://github.com/TogetsuDo/nonebot-plugin-bot-monitor@master
pdm
pdm add nonebot-plugin-bot-monitor
安装仓库 master 分支
pdm add git+https://github.com/TogetsuDo/nonebot-plugin-bot-monitor@master
poetry
poetry add nonebot-plugin-bot-monitor
安装仓库 master 分支
poetry add git+https://github.com/TogetsuDo/nonebot-plugin-bot-monitor@master
打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入
plugins = ["nonebot_plugin_bot_monitor"]
⚙️ 配置
在 nonebot2 项目的 .env 文件中添加以下配置:
| 配置项 | 必填 | 默认值 | 说明 |
|---|---|---|---|
BOT_monitor_SMTP_USER |
否 | 无 | SMTP 发件人账号 |
BOT_monitor_SMTP_PASSWORD |
否 | 无 | SMTP 授权码(非登录密码) |
BOT_monitor_SMTP_SERVER |
否 | 无 | SMTP 服务器地址 |
BOT_monitor_SMTP_PORT |
否 | 465 |
SMTP 端口,465 使用 SSL,其他端口使用 STARTTLS |
BOT_monitor_NOTICE_EMAIL |
否 | 无 | 接收离线通知的邮箱 |
BOT_monitor_OFFLINE_GRACE_TIME |
否 | 30 |
离线宽限期(秒),Bot 在此时间内重连则不发送通知 |
BOT_monitor_ADMIN_EMAILS |
否 | [] |
额外通知邮箱列表,离线时同时通知这些邮箱 |
BOT_monitor_CMD_BOT_status |
否 | Bot在吗 |
查询 Bot 状态的命令名 |
BOT_monitor_CMD_TEST_MAIL |
否 | 测试邮件 |
测试邮件发送的命令名 |
BOT_monitor_SMTP_USER=your@email.com
BOT_monitor_SMTP_PASSWORD=your_auth_code
BOT_monitor_SMTP_SERVER=smtp.example.com
BOT_monitor_SMTP_PORT=465
BOT_monitor_NOTICE_EMAIL=receiver@email.com
BOT_monitor_OFFLINE_GRACE_TIME=30
BOT_monitor_ADMIN_EMAILS=["admin1@qq.com", "admin2@qq.com"]
# 可选:自定义命令名
BOT_monitor_CMD_BOT_status=Bot在吗
BOT_monitor_CMD_TEST_MAIL=测试邮件
邮箱配置请参考各邮件服务商的 SMTP 设置说明(QQ 邮箱、163 邮箱等均需使用授权码而非登录密码)。
🎉 使用
无需任何插件配置即可使用
Bot在吗命令,只需在.env中设置 NoneBot2 的超级用户:SUPERUSERS=["你的QQ号"]邮件通知功能才需要额外配置
BOT_monitor_SMTP_*相关项。
以下命令仅 SUPERUSERS 可用:
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|---|---|---|---|---|
Bot在吗(可自定义) |
超级用户 | 否 | 群聊/私聊 | 查询所有 Bot 的在线/离线状态 |
测试邮件(可自定义) |
超级用户 | 否 | 群聊/私聊 | 向配置的邮箱发送测试邮件,验证邮件配置是否正确 |
依赖
- nonebot2 >= 2.4.0
- nonebot-adapter-onebot >= 2.4.0
- nonebot-plugin-apscheduler >= 0.5.0
- aiosmtplib >= 5.0.0
License
MIT
Metadata
Release files for nonebot-plugin-bot-monitor 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nonebot_plugin_bot_monitor-1.0.4.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nonebot_plugin_bot_monitor-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.4 kB
Release files / nonebot_plugin_bot_monitor-1.0.4.tar.gz
| Download URL | nonebot_plugin_bot_monitor-1.0.4.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc7a3aacc26e5de94dc3f7ab36faedafad9d802b6d4f643cf4d20a93ee22d0e4
|
|
BLAKE2b-256 checksum How to use checksums |
c02df53bfaf03702f2d80f118c51bd146be444c8712bab1396eb9766accb6614
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / nonebot_plugin_bot_monitor-1.0.4-py3-none-any.whl
| Download URL | nonebot_plugin_bot_monitor-1.0.4-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79972693e743cde6098dabc894f4e4306c4ea89a3430d9f6dffe6397d5604700
|
|
BLAKE2b-256 checksum How to use checksums |
f29f676168db25eaf964d48ff9aacda69c53d46d9e6ca562d8d07a847f6c8917
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|