<!-- markdownlint-disable MD033 MD036 MD041-->
<div align="center">
# nonebot-plugin-push
_✨ 消息推送插件 ✨_
</div>
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/nonebot-plugin-push)
![PyPI](https://img.shields.io/pypi/v/nonebot-plugin-push)
![GitHub](https://img.shields.io/github/license/mobyw/nonebot-plugin-push)
## 简介
本插件提供通过邮件、Feishu Webhook 方式进行消息推送,支持纯文本与 Markdown 格式的内容。
## 安装步骤
### 使用 `nb-cli` 安装(推荐)
```bash
nb plugin install nonebot-plugin-push
```
### 使用 `pip` 安装
```bash
pip install nonebot-plugin-push
```
需要在 bot 根目录 `pyproject.toml` 文件中 [tool.nonebot] 部分添加:
```python
plugins = ["nonebot_plugin_push"]
```
## 配置
### 账号配置
当前支持通过邮件和 Feishu Webhook 进行推送,配置示例如下:
```dotenv
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` 字段唯一,下表为单个账号配置中各字段的说明:
| | Mail | Feishu Webhook |
| ---------- | --------------------- | ------------------ |
| `name` | 推送名称 | 推送名称 |
| `type` | 固定为 "mail" | 固定为 "feishu" |
| `url` | SMTP 连接主机与端口号 | webhook url |
| `username` | 账号名(邮箱账号) | - |
| `password` | SMTP 连接密钥 | 签名校验密钥,可选 |
| `targets` | 推送邮箱列表 | - |
### Driver
若使用 Feishu Webhook,需要参考 [driver](https://nonebot.dev/docs/appendices/config#driver) 配置项,添加 `ForwardDriver` 支持。
## 跨插件使用
导入方式:
```python
from nonebot import require
require("nonebot_plugin_push")
```
使用方式:
```python
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, "推送消息标题(可选)")
```
获取特定的推送账号:
```python
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 模块](https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/using-markdown-tags#abc9b025) 文档。
Raw data
{
"_id": null,
"home_page": "https://github.com/mobyw/nonebot-plugin-push",
"name": "nonebot-plugin-push",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "nonebot2,plugin,push",
"author": "mobyw",
"author_email": "mobyw66@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f5/0e/f2cc825f55058870304b0f1f5e1f21c081d9bbbc7643ceae2a67823f3b8b/nonebot_plugin_push-0.1.0.tar.gz",
"platform": null,
"description": "<!-- markdownlint-disable MD033 MD036 MD041-->\n\n<div align=\"center\">\n\n# nonebot-plugin-push\n\n_\u2728 \u6d88\u606f\u63a8\u9001\u63d2\u4ef6 \u2728_\n\n</div>\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/nonebot-plugin-push)\n![PyPI](https://img.shields.io/pypi/v/nonebot-plugin-push)\n![GitHub](https://img.shields.io/github/license/mobyw/nonebot-plugin-push)\n\n## \u7b80\u4ecb\n\n\u672c\u63d2\u4ef6\u63d0\u4f9b\u901a\u8fc7\u90ae\u4ef6\u3001Feishu Webhook \u65b9\u5f0f\u8fdb\u884c\u6d88\u606f\u63a8\u9001\uff0c\u652f\u6301\u7eaf\u6587\u672c\u4e0e Markdown \u683c\u5f0f\u7684\u5185\u5bb9\u3002\n\n## \u5b89\u88c5\u6b65\u9aa4\n\n### \u4f7f\u7528 `nb-cli` \u5b89\u88c5\uff08\u63a8\u8350\uff09\n\n```bash\nnb plugin install nonebot-plugin-push\n```\n\n### \u4f7f\u7528 `pip` \u5b89\u88c5\n\n```bash\npip install nonebot-plugin-push\n```\n\n\u9700\u8981\u5728 bot \u6839\u76ee\u5f55 `pyproject.toml` \u6587\u4ef6\u4e2d [tool.nonebot] \u90e8\u5206\u6dfb\u52a0\uff1a\n\n```python\nplugins = [\"nonebot_plugin_push\"]\n```\n\n## \u914d\u7f6e\n\n### \u8d26\u53f7\u914d\u7f6e\n\n\u5f53\u524d\u652f\u6301\u901a\u8fc7\u90ae\u4ef6\u548c Feishu Webhook \u8fdb\u884c\u63a8\u9001\uff0c\u914d\u7f6e\u793a\u4f8b\u5982\u4e0b\uff1a\n\n```dotenv\nPUSH_ACCOUNTS='\n[\n {\n \"name\": \"push1\",\n \"type\": \"mail\",\n \"url\": \"smtp://smtp.example.com:465\",\n \"username\": \"name@example.com\",\n \"password\": \"password\",\n \"targets\": [ \"to@example.com\" ]\n },\n {\n \"name\": \"push2\",\n \"type\": \"feishu\",\n \"url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx\",\n \"password\": \"password\"\n }\n]\n'\n```\n\n\u5982\u9700\u6309\u540d\u79f0\u83b7\u53d6\u63a8\u9001\u8d26\u53f7\uff0c\u8bf7\u4fdd\u8bc1 `name` \u5b57\u6bb5\u552f\u4e00\uff0c\u4e0b\u8868\u4e3a\u5355\u4e2a\u8d26\u53f7\u914d\u7f6e\u4e2d\u5404\u5b57\u6bb5\u7684\u8bf4\u660e\uff1a\n\n| | Mail | Feishu Webhook |\n| ---------- | --------------------- | ------------------ |\n| `name` | \u63a8\u9001\u540d\u79f0 | \u63a8\u9001\u540d\u79f0 |\n| `type` | \u56fa\u5b9a\u4e3a \"mail\" | \u56fa\u5b9a\u4e3a \"feishu\" |\n| `url` | SMTP \u8fde\u63a5\u4e3b\u673a\u4e0e\u7aef\u53e3\u53f7 | webhook url |\n| `username` | \u8d26\u53f7\u540d\uff08\u90ae\u7bb1\u8d26\u53f7\uff09 | - |\n| `password` | SMTP \u8fde\u63a5\u5bc6\u94a5 | \u7b7e\u540d\u6821\u9a8c\u5bc6\u94a5\uff0c\u53ef\u9009 |\n| `targets` | \u63a8\u9001\u90ae\u7bb1\u5217\u8868 | - |\n\n### Driver\n\n\u82e5\u4f7f\u7528 Feishu Webhook\uff0c\u9700\u8981\u53c2\u8003 [driver](https://nonebot.dev/docs/appendices/config#driver) \u914d\u7f6e\u9879\uff0c\u6dfb\u52a0 `ForwardDriver` \u652f\u6301\u3002\n\n## \u8de8\u63d2\u4ef6\u4f7f\u7528\n\n\u5bfc\u5165\u65b9\u5f0f\uff1a\n\n```python\nfrom nonebot import require\nrequire(\"nonebot_plugin_push\")\n```\n\n\u4f7f\u7528\u65b9\u5f0f\uff1a\n\n```python\nfrom nonebot_plugin_push import MessageSegment, get_push, get_push_list\n\nmessage = MessageSegment.markdown('**Markdown**<font color=\"red\">\u6587\u672c</font>') + '\u666e\u901a\u6587\u672c'\npush = get_push()\nif push is not None:\n await push.send(message, \"\u63a8\u9001\u6d88\u606f\u6807\u9898\uff08\u53ef\u9009\uff09\")\n```\n\n\u83b7\u53d6\u7279\u5b9a\u7684\u63a8\u9001\u8d26\u53f7\uff1a\n\n```python\nfrom nonebot_plugin_push import get_push, get_push_list\n\n# \u83b7\u53d6\u7b2c\u4e00\u4e2a\u63a8\u9001\u8d26\u53f7\npush = get_push()\n# \u83b7\u53d6\u4e00\u4e2a\u6307\u5b9a\u540d\u79f0\u7684\u63a8\u9001\u8d26\u53f7\npush = get_push(name=\"push1\")\n# \u83b7\u53d6\u4e00\u4e2a\u6307\u5b9a\u7c7b\u578b\u7684\u63a8\u9001\u8d26\u53f7\npush = get_push(type=\"mail\")\n# \u83b7\u53d6\u6307\u5b9a\u7c7b\u578b\u7684\u63a8\u9001\u8d26\u53f7\u5217\u8868\npush = get_push_list(type=\"feishu\")\n```\n\n## \u5176\u4ed6\u8bf4\u660e\n\nFeishu Webhook \u4ec5\u652f\u6301\u90e8\u5206 Markdown \u8bed\u6cd5\uff0c\u5177\u4f53\u8bf7\u67e5\u9605 [Markdown \u6a21\u5757](https://open.feishu.cn/document/common-capabilities/message-card/message-cards-content/using-markdown-tags#abc9b025) \u6587\u6863\u3002\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u6d88\u606f\u63a8\u9001\u63d2\u4ef6",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/mobyw/nonebot-plugin-push/blob/main/README.md",
"Homepage": "https://github.com/mobyw/nonebot-plugin-push",
"Repository": "https://github.com/mobyw/nonebot-plugin-push"
},
"split_keywords": [
"nonebot2",
"plugin",
"push"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "185509aba77ed56031c3cedcf1b8fb6a63f6a918e4ad4ef2f065701fb0a2bd48",
"md5": "7d75c8eebaab3594f2d2419acd84afee",
"sha256": "0b4e79c02f41f2872afdc678183261cd229790ce363fa89bb7c3a274bf1493c6"
},
"downloads": -1,
"filename": "nonebot_plugin_push-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7d75c8eebaab3594f2d2419acd84afee",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 9453,
"upload_time": "2023-08-15T07:00:53",
"upload_time_iso_8601": "2023-08-15T07:00:53.896995Z",
"url": "https://files.pythonhosted.org/packages/18/55/09aba77ed56031c3cedcf1b8fb6a63f6a918e4ad4ef2f065701fb0a2bd48/nonebot_plugin_push-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f50ef2cc825f55058870304b0f1f5e1f21c081d9bbbc7643ceae2a67823f3b8b",
"md5": "ed2d07648a4e8d693ba7c22e5a5ff5e4",
"sha256": "1a87185fbf2898cb8af51f3c448a9963489b9c2821a268dc4b62162d1bb6992c"
},
"downloads": -1,
"filename": "nonebot_plugin_push-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ed2d07648a4e8d693ba7c22e5a5ff5e4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 7046,
"upload_time": "2023-08-15T07:00:55",
"upload_time_iso_8601": "2023-08-15T07:00:55.988668Z",
"url": "https://files.pythonhosted.org/packages/f5/0e/f2cc825f55058870304b0f1f5e1f21c081d9bbbc7643ceae2a67823f3b8b/nonebot_plugin_push-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-15 07:00:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mobyw",
"github_project": "nonebot-plugin-push",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nonebot-plugin-push"
}