NoneBot2 插件:监控 Bot 在线状态,检测 Bot 离线并发送邮件通知
Project description
📖 介绍
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 邮箱等均需使用授权码而非登录密码)。
🎉 使用
以下命令仅 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_bot_monitor-1.0.1.tar.gz.
File metadata
- Download URL: nonebot_plugin_bot_monitor-1.0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da1d0a486a8d25c71f9a200827b4bf6209e70eef629e6d8fd0d6979068a22976
|
|
| MD5 |
d9680166d89d7def707480086d0e1bb6
|
|
| BLAKE2b-256 |
76ce5c360c94701898db199b6a8360c886c4e31ae05641adc896af44472d395a
|
File details
Details for the file nonebot_plugin_bot_monitor-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_bot_monitor-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9422c6d3bd8eb69e03f116c86a611baf120f57f6059c7f620661ec51d683a937
|
|
| MD5 |
24daf06613c9a68a9008ce652aed960f
|
|
| BLAKE2b-256 |
fd50b3ff3156bfebee33db14509ee2021bdc67075699c59ee0756f8f49e9d464
|