[TOC]
# sais-notify
## 介绍
SAIS 消息通知服务Python SDK,方便开发者快速集成消息通知服务。
### 功能
**DONE:**
- 飞书用户文本通知
- 飞书用户富文本通知
- 飞书用户文本通知
- 飞书用户富文本通知
**TODO:**
- 邮箱通知
- 短信通知
### 使用
> 安装sais-notify
```bash
pip install sais-notify -U
```
> 使用sais-notify
### 给飞书用户发送文本消息
```python
from sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType
# 需设置环境变量SAIS_NOTIFY_AUTH_TOKEN
credentials_provider = EnvVarCredentialsProvider()
message_handler = MessageHandler(credentials_provider)
message_handler.send_notification(NotifyType.FEISHU_USER_TEXT, to="手机号,多个逗号隔开", message="文本内容")
```
### 给飞书用户发送富文本消息
```python
from sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType
# 需设置环境变量SAIS_NOTIFY_AUTH_TOKEN
credentials_provider = EnvVarCredentialsProvider()
message_handler = MessageHandler(credentials_provider)
message_handler.send_notification(NotifyType.FEISHU_USER_RICH_TEXT, to="手机号,多个逗号隔开", message='{\"zh_cn\":{\"title\":\"我是一个标题\",\"content\":[[{\"tag\":\"text\",\"text\":\"第一行 :\"},{\"tag\":\"a\",\"href\":\"http://www.feishu.cn\",\"text\":\"超链接\"},{\"tag\":\"at\",\"user_id\":\"ou_1avnmsbv3k45jnk34j5\",\"user_name\":\"tom\"}],[{\"tag\":\"img\",\"image_key\":\"img_7ea74629-9191-4176-998c-2e603c9c5e8g\"}],[{\"tag\":\"text\",\"text\":\"第二行:\"},{\"tag\":\"text\",\"text\":\"文本测试\"}],[{\"tag\":\"img\",\"image_key\":\"img_7ea74629-9191-4176-998c-2e603c9c5e8g\"}]]}}')
```
### 给飞书群组发送文本消息
```python
from sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType
# 需设置环境变量SAIS_NOTIFY_AUTH_TOKEN
credentials_provider = EnvVarCredentialsProvider()
message_handler = MessageHandler(credentials_provider)
message_handler.send_notification(NotifyType.FEISHU_GROUP_TEXT, to="群组id,多个逗号隔开", message='文本消息')
```
### 给飞书群组发送文本消息
```python
from sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType
# 需设置环境变量SAIS_NOTIFY_AUTH_TOKEN
credentials_provider = EnvVarCredentialsProvider()
message_handler = MessageHandler(credentials_provider)
message_handler.send_notification(NotifyType.FEISHU_GROUP_MESSAGE_CARD, to="群组id,多个逗号隔开", message='{\"config\":{\"wide_screen_mode\":true},\"elements\":[{\"alt\":{\"content\":\"\",\"tag\":\"plain_text\"},\"img_key\":\"img_7ea74629-9191-4176-998c-2e603c9c5e8g\",\"tag\":\"img\"},{\"tag\":\"div\",\"text\":{\"content\":\"你是否曾因为一本书而产生心灵共振,开始感悟人生?\\n你有哪些想极力推荐给他人的珍藏书单?\\n\\n加入 **4·23 飞书读书节**,分享你的**挚爱书单**及**读书笔记**,**赢取千元读书礼**!\\n\\n📬 填写问卷,晒出你的珍藏好书\\n😍 想知道其他人都推荐了哪些好书?马上[入群围观](https://open.feishu.cn/)\\n📝 用[读书笔记模板](https://open.feishu.cn/)(桌面端打开),记录你的心得体会\\n🙌 更有惊喜特邀嘉宾 4月12日起带你共读\",\"tag\":\"lark_md\"}},{\"actions\":[{\"tag\":\"button\",\"text\":{\"content\":\"立即推荐好书\",\"tag\":\"plain_text\"},\"type\":\"primary\",\"url\":\"https://open.feishu.cn/\"},{\"tag\":\"button\",\"text\":{\"content\":\"查看活动指南\",\"tag\":\"plain_text\"},\"type\":\"default\",\"url\":\"https://open.feishu.cn/\"}],\"tag\":\"action\"}],\"header\":{\"template\":\"turquoise\",\"title\":{\"content\":\"📚晒挚爱好书,赢读书礼金\",\"tag\":\"plain_text\"}}}')
```
## 代码结构
```
├── README.md
├── pyproject.toml
└── sais
├── __init__.py
└── notify
├── __init__.py
├── auth
│ ├── __init__.py
│ └── auth_info.py
├── clients
│ ├── __init__.py
│ └── notify_client.py
├── config
│ ├── __init__.py
│ ├── const.py
│ └── version.py
├── handler
│ ├── __init__.py
│ └── message_handler.py
├── model
│ ├── __init__.py
│ └── message_model.py
├── requirements.txt
└── types
└── __init__.py
```
## 更多
**联系我们:** SAIS 团队
Raw data
{
"_id": null,
"home_page": null,
"name": "sais-notify-test",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "sais, sais-notify-test",
"author": "SAIS Contributors",
"author_email": "sais@example.com",
"download_url": "https://files.pythonhosted.org/packages/f0/39/93b3557506ce417a8441ea4eb7802438022697bfd564b522acaa8f3bc7fb/sais_notify_test-0.0.22.tar.gz",
"platform": null,
"description": "[TOC]\n\n# sais-notify\n\n## \u4ecb\u7ecd\nSAIS \u6d88\u606f\u901a\u77e5\u670d\u52a1Python SDK\uff0c\u65b9\u4fbf\u5f00\u53d1\u8005\u5feb\u901f\u96c6\u6210\u6d88\u606f\u901a\u77e5\u670d\u52a1\u3002\n\n### \u529f\u80fd\n\n**DONE\uff1a**\n- \u98de\u4e66\u7528\u6237\u6587\u672c\u901a\u77e5\n- \u98de\u4e66\u7528\u6237\u5bcc\u6587\u672c\u901a\u77e5\n- \u98de\u4e66\u7528\u6237\u6587\u672c\u901a\u77e5\n- \u98de\u4e66\u7528\u6237\u5bcc\u6587\u672c\u901a\u77e5\n\n**TODO\uff1a**\n- \u90ae\u7bb1\u901a\u77e5 \n- \u77ed\u4fe1\u901a\u77e5\n\n### \u4f7f\u7528\n\n> \u5b89\u88c5sais-notify\n\n```bash \npip install sais-notify -U\n```\n\n> \u4f7f\u7528sais-notify\n\n### \u7ed9\u98de\u4e66\u7528\u6237\u53d1\u9001\u6587\u672c\u6d88\u606f\n\n```python\nfrom sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType\n# \u9700\u8bbe\u7f6e\u73af\u5883\u53d8\u91cfSAIS_NOTIFY_AUTH_TOKEN\ncredentials_provider = EnvVarCredentialsProvider()\nmessage_handler = MessageHandler(credentials_provider)\nmessage_handler.send_notification(NotifyType.FEISHU_USER_TEXT, to=\"\u624b\u673a\u53f7\uff0c\u591a\u4e2a\u9017\u53f7\u9694\u5f00\", message=\"\u6587\u672c\u5185\u5bb9\")\n```\n\n### \u7ed9\u98de\u4e66\u7528\u6237\u53d1\u9001\u5bcc\u6587\u672c\u6d88\u606f\n\n```python\nfrom sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType\n# \u9700\u8bbe\u7f6e\u73af\u5883\u53d8\u91cfSAIS_NOTIFY_AUTH_TOKEN\ncredentials_provider = EnvVarCredentialsProvider()\nmessage_handler = MessageHandler(credentials_provider)\nmessage_handler.send_notification(NotifyType.FEISHU_USER_RICH_TEXT, to=\"\u624b\u673a\u53f7\uff0c\u591a\u4e2a\u9017\u53f7\u9694\u5f00\", message='{\\\"zh_cn\\\":{\\\"title\\\":\\\"\u6211\u662f\u4e00\u4e2a\u6807\u9898\\\",\\\"content\\\":[[{\\\"tag\\\":\\\"text\\\",\\\"text\\\":\\\"\u7b2c\u4e00\u884c :\\\"},{\\\"tag\\\":\\\"a\\\",\\\"href\\\":\\\"http://www.feishu.cn\\\",\\\"text\\\":\\\"\u8d85\u94fe\u63a5\\\"},{\\\"tag\\\":\\\"at\\\",\\\"user_id\\\":\\\"ou_1avnmsbv3k45jnk34j5\\\",\\\"user_name\\\":\\\"tom\\\"}],[{\\\"tag\\\":\\\"img\\\",\\\"image_key\\\":\\\"img_7ea74629-9191-4176-998c-2e603c9c5e8g\\\"}],[{\\\"tag\\\":\\\"text\\\",\\\"text\\\":\\\"\u7b2c\u4e8c\u884c:\\\"},{\\\"tag\\\":\\\"text\\\",\\\"text\\\":\\\"\u6587\u672c\u6d4b\u8bd5\\\"}],[{\\\"tag\\\":\\\"img\\\",\\\"image_key\\\":\\\"img_7ea74629-9191-4176-998c-2e603c9c5e8g\\\"}]]}}')\n```\n### \u7ed9\u98de\u4e66\u7fa4\u7ec4\u53d1\u9001\u6587\u672c\u6d88\u606f\n```python\nfrom sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType\n# \u9700\u8bbe\u7f6e\u73af\u5883\u53d8\u91cfSAIS_NOTIFY_AUTH_TOKEN\ncredentials_provider = EnvVarCredentialsProvider()\nmessage_handler = MessageHandler(credentials_provider)\nmessage_handler.send_notification(NotifyType.FEISHU_GROUP_TEXT, to=\"\u7fa4\u7ec4id\uff0c\u591a\u4e2a\u9017\u53f7\u9694\u5f00\", message='\u6587\u672c\u6d88\u606f')\n\n```\n\n### \u7ed9\u98de\u4e66\u7fa4\u7ec4\u53d1\u9001\u6587\u672c\u6d88\u606f\n```python\nfrom sais.notify import MessageHandler, EnvVarCredentialsProvider, NotifyType\n# \u9700\u8bbe\u7f6e\u73af\u5883\u53d8\u91cfSAIS_NOTIFY_AUTH_TOKEN\ncredentials_provider = EnvVarCredentialsProvider()\nmessage_handler = MessageHandler(credentials_provider)\nmessage_handler.send_notification(NotifyType.FEISHU_GROUP_MESSAGE_CARD, to=\"\u7fa4\u7ec4id\uff0c\u591a\u4e2a\u9017\u53f7\u9694\u5f00\", message='{\\\"config\\\":{\\\"wide_screen_mode\\\":true},\\\"elements\\\":[{\\\"alt\\\":{\\\"content\\\":\\\"\\\",\\\"tag\\\":\\\"plain_text\\\"},\\\"img_key\\\":\\\"img_7ea74629-9191-4176-998c-2e603c9c5e8g\\\",\\\"tag\\\":\\\"img\\\"},{\\\"tag\\\":\\\"div\\\",\\\"text\\\":{\\\"content\\\":\\\"\u4f60\u662f\u5426\u66fe\u56e0\u4e3a\u4e00\u672c\u4e66\u800c\u4ea7\u751f\u5fc3\u7075\u5171\u632f\uff0c\u5f00\u59cb\u611f\u609f\u4eba\u751f\uff1f\\\\n\u4f60\u6709\u54ea\u4e9b\u60f3\u6781\u529b\u63a8\u8350\u7ed9\u4ed6\u4eba\u7684\u73cd\u85cf\u4e66\u5355\uff1f\\\\n\\\\n\u52a0\u5165 **4\u00b723 \u98de\u4e66\u8bfb\u4e66\u8282**\uff0c\u5206\u4eab\u4f60\u7684**\u631a\u7231\u4e66\u5355**\u53ca**\u8bfb\u4e66\u7b14\u8bb0**\uff0c**\u8d62\u53d6\u5343\u5143\u8bfb\u4e66\u793c**\uff01\\\\n\\\\n\ud83d\udcec \u586b\u5199\u95ee\u5377\uff0c\u6652\u51fa\u4f60\u7684\u73cd\u85cf\u597d\u4e66\\\\n\ud83d\ude0d \u60f3\u77e5\u9053\u5176\u4ed6\u4eba\u90fd\u63a8\u8350\u4e86\u54ea\u4e9b\u597d\u4e66\uff1f\u9a6c\u4e0a[\u5165\u7fa4\u56f4\u89c2](https://open.feishu.cn/)\\\\n\ud83d\udcdd \u7528[\u8bfb\u4e66\u7b14\u8bb0\u6a21\u677f](https://open.feishu.cn/)\uff08\u684c\u9762\u7aef\u6253\u5f00\uff09\uff0c\u8bb0\u5f55\u4f60\u7684\u5fc3\u5f97\u4f53\u4f1a\\\\n\ud83d\ude4c \u66f4\u6709\u60ca\u559c\u7279\u9080\u5609\u5bbe 4\u670812\u65e5\u8d77\u5e26\u4f60\u5171\u8bfb\\\",\\\"tag\\\":\\\"lark_md\\\"}},{\\\"actions\\\":[{\\\"tag\\\":\\\"button\\\",\\\"text\\\":{\\\"content\\\":\\\"\u7acb\u5373\u63a8\u8350\u597d\u4e66\\\",\\\"tag\\\":\\\"plain_text\\\"},\\\"type\\\":\\\"primary\\\",\\\"url\\\":\\\"https://open.feishu.cn/\\\"},{\\\"tag\\\":\\\"button\\\",\\\"text\\\":{\\\"content\\\":\\\"\u67e5\u770b\u6d3b\u52a8\u6307\u5357\\\",\\\"tag\\\":\\\"plain_text\\\"},\\\"type\\\":\\\"default\\\",\\\"url\\\":\\\"https://open.feishu.cn/\\\"}],\\\"tag\\\":\\\"action\\\"}],\\\"header\\\":{\\\"template\\\":\\\"turquoise\\\",\\\"title\\\":{\\\"content\\\":\\\"\ud83d\udcda\u6652\u631a\u7231\u597d\u4e66\uff0c\u8d62\u8bfb\u4e66\u793c\u91d1\\\",\\\"tag\\\":\\\"plain_text\\\"}}}')\n```\n\n\n## \u4ee3\u7801\u7ed3\u6784\n```\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 pyproject.toml\n\u2514\u2500\u2500 sais\n \u251c\u2500\u2500 __init__.py\n \u2514\u2500\u2500 notify\n \u251c\u2500\u2500 __init__.py\n \u251c\u2500\u2500 auth\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 auth_info.py\n \u251c\u2500\u2500 clients\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 notify_client.py\n \u251c\u2500\u2500 config\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 const.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 version.py\n \u251c\u2500\u2500 handler\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 message_handler.py\n \u251c\u2500\u2500 model\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 message_model.py\n \u251c\u2500\u2500 requirements.txt\n \u2514\u2500\u2500 types\n \u2514\u2500\u2500 __init__.py\n```\n\n## \u66f4\u591a\n**\u8054\u7cfb\u6211\u4eec\uff1a** SAIS \u56e2\u961f\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "sais notify python sdk",
"version": "0.0.22",
"project_urls": {
"repository": "https://github.com/xxx/xxxx"
},
"split_keywords": [
"sais",
" sais-notify-test"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8c11d537bab799bad734f4b43ba03ec1ff02503d736e8f22d60ab0611edc93a8",
"md5": "3bbce2454a0d8697bbbb45747d2c844e",
"sha256": "bd53bfb7abcf9f652d2b57af898d52e9b91d341905a55fc816318ececacedaf6"
},
"downloads": -1,
"filename": "sais_notify_test-0.0.22-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3bbce2454a0d8697bbbb45747d2c844e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7584,
"upload_time": "2024-05-20T10:07:11",
"upload_time_iso_8601": "2024-05-20T10:07:11.610688Z",
"url": "https://files.pythonhosted.org/packages/8c/11/d537bab799bad734f4b43ba03ec1ff02503d736e8f22d60ab0611edc93a8/sais_notify_test-0.0.22-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f03993b3557506ce417a8441ea4eb7802438022697bfd564b522acaa8f3bc7fb",
"md5": "4874a0c4fbbc3893ddb8d6d3c33e0e9f",
"sha256": "fd8100191921faff32fea3f463b3af0283c5f947199512579b0caa31d29caa34"
},
"downloads": -1,
"filename": "sais_notify_test-0.0.22.tar.gz",
"has_sig": false,
"md5_digest": "4874a0c4fbbc3893ddb8d6d3c33e0e9f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4765,
"upload_time": "2024-05-20T10:07:14",
"upload_time_iso_8601": "2024-05-20T10:07:14.089199Z",
"url": "https://files.pythonhosted.org/packages/f0/39/93b3557506ce417a8441ea4eb7802438022697bfd564b522acaa8f3bc7fb/sais_notify_test-0.0.22.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-20 10:07:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xxx",
"github_project": "xxxx",
"github_not_found": true,
"lcname": "sais-notify-test"
}