消息推送插件
Project description
nonebot-plugin-push
✨ 消息推送插件 ✨
简介
本插件提供通过邮件、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 模块 文档。
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for nonebot_plugin_push-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a87185fbf2898cb8af51f3c448a9963489b9c2821a268dc4b62162d1bb6992c |
|
MD5 | ed2d07648a4e8d693ba7c22e5a5ff5e4 |
|
BLAKE2b-256 | f50ef2cc825f55058870304b0f1f5e1f21c081d9bbbc7643ceae2a67823f3b8b |
Close
Hashes for nonebot_plugin_push-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b4e79c02f41f2872afdc678183261cd229790ce363fa89bb7c3a274bf1493c6 |
|
MD5 | 7d75c8eebaab3594f2d2419acd84afee |
|
BLAKE2b-256 | 185509aba77ed56031c3cedcf1b8fb6a63f6a918e4ad4ef2f065701fb0a2bd48 |