Skip to main content

NoneBot2 插件:监控 Bot 在线状态,检测 Bot 离线并发送邮件通知

Project description

logo

✨ nonebot-plugin-bot-monitor ✨

LICENSE pypi python uv
ruff pre-commit

📖 介绍

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 的在线/离线状态
测试邮件(可自定义) 超级用户 群聊/私聊 向配置的邮箱发送测试邮件,验证邮件配置是否正确

依赖

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

nonebot_plugin_bot_monitor-1.0.3.tar.gz (8.3 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_bot_monitor-1.0.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_bot_monitor-1.0.3.tar.gz.

File metadata

  • Download URL: nonebot_plugin_bot_monitor-1.0.3.tar.gz
  • Upload date:
  • Size: 8.3 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

Hashes for nonebot_plugin_bot_monitor-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ed99cd5325451a93db39651e179bd8991a16e477186f421b9bb1837556642e55
MD5 3277d6d1c9bd1ebfd5f7056f4a3496c3
BLAKE2b-256 b97d67b687f735d5fbafbef7424229f15f7ecde88334e7416331d875bb8187fe

See more details on using hashes here.

File details

Details for the file nonebot_plugin_bot_monitor-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: nonebot_plugin_bot_monitor-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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

Hashes for nonebot_plugin_bot_monitor-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4d0d81eb1cc1f946a1edd6c9a149846503959177fcb578ac208d74d98d677557
MD5 91628b5db0a8d6731ee6d7ee029ff8cc
BLAKE2b-256 75a71cb4437568b9c7e95b5c344395a261426620997d9ed86624d26791abeb4a

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