简介
本插件提供通过邮件、Feishu Webhook 方式进行消息推送,支持纯文本与 Markdown 格式的内容。
安装步骤
使用 nb-cli 安装(推荐)
nb plugin install nonebot-plugin-push
使用 pip 安装
pip install nonebot-plugin-push
需要在 bot 根目录 pyproject.toml 文件中 [tool.nonebot] 部分添加:
plugins = ["nonebot_plugin_push"]
配置
账号配置
当前支持通过邮件和 Feishu Webhook 进行推送,配置示例如下:
PUSH_ACCOUNTS='
[
{
"name": "push1",
"type": "mail",
"url": "smtp://smtp.example.com:465",
"username": "name@example.com",
"password": "password",
"targets": [ "to@example.com" ]
},
{
"name": "push2",
"type": "feishu",
"url": "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx",
"password": "password"
}
]
'
如需按名称获取推送账号,请保证 name 字段唯一,下表为单个账号配置中各字段的说明:
| Feishu Webhook | ||
|---|---|---|
name |
推送名称 | 推送名称 |
type |
固定为 "mail" | 固定为 "feishu" |
url |
SMTP 连接主机与端口号 | webhook url |
username |
账号名(邮箱账号) | - |
password |
SMTP 连接密钥 | 签名校验密钥,可选 |
targets |
推送邮箱列表 | - |
Driver
若使用 Feishu Webhook,需要参考 driver 配置项,添加 ForwardDriver 支持。
跨插件使用
导入方式:
from nonebot import require
require("nonebot_plugin_push")
使用方式:
from nonebot_plugin_push import MessageSegment, get_push, get_push_list
message = MessageSegment.markdown('**Markdown**<font color="red">文本</font>') + '普通文本'
push = get_push()
if push is not None:
await push.send(message, "推送消息标题(可选)")
获取特定的推送账号:
from nonebot_plugin_push import get_push, get_push_list
# 获取第一个推送账号
push = get_push()
# 获取一个指定名称的推送账号
push = get_push(name="push1")
# 获取一个指定类型的推送账号
push = get_push(type="mail")
# 获取指定类型的推送账号列表
push = get_push_list(type="feishu")
其他说明
Feishu Webhook 仅支持部分 Markdown 语法,具体请查阅 Markdown 模块 文档。
Metadata
Release files for nonebot-plugin-push 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_plugin_push-0.1.0.tar.gz | 7.0 kB | Without provenance | Details for nonebot_plugin_push-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_push-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_push-0.1.0-py3-none-any.whl |
Total release size: 16.5 kB
Release files / nonebot_plugin_push-0.1.0.tar.gz
| Download URL | nonebot_plugin_push-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a87185fbf2898cb8af51f3c448a9963489b9c2821a268dc4b62162d1bb6992c
|
|
BLAKE2b-256 checksum How to use checksums |
f50ef2cc825f55058870304b0f1f5e1f21c081d9bbbc7643ceae2a67823f3b8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.10 Windows/10
|
Release files / nonebot_plugin_push-0.1.0-py3-none-any.whl
| Download URL | nonebot_plugin_push-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b4e79c02f41f2872afdc678183261cd229790ce363fa89bb7c3a274bf1493c6
|
|
BLAKE2b-256 checksum How to use checksums |
185509aba77ed56031c3cedcf1b8fb6a63f6a918e4ad4ef2f065701fb0a2bd48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.10 Windows/10
|
Security for nonebot-plugin-push 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.