sais-notify


Namesais-notify JSON
Version 0.0.15 PyPI version JSON
download
home_pageNone
Summarysais notify python sdk
upload_time2024-10-14 06:05:32
maintainerNone
docs_urlNone
authorSAIS Contributors
requires_python>=3.8
licenseApache License 2.0
keywords sais sais-notify
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [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\"}}}')
```

### 发送邮件
```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.EMAIL, to="邮箱,多个逗号隔开", message="邮件正文内容", subject="邮件主题")
```

### 发送短信
```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.SMS, to="手机号,多个逗号隔开", message="短信变量参数,类型jsonstring", sign_name="签名", template_code="模板名称")
```

## 代码结构
```
├── 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
        └── types
            └── __init__.py
```

## 更多
**联系我们:** SAIS 团队

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sais-notify",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "sais, sais-notify",
    "author": "SAIS Contributors",
    "author_email": "sais@example.com",
    "download_url": "https://files.pythonhosted.org/packages/fc/0c/69c067b4740fe936d0e535081a19bc895f8ab764819a1dacb72ce5977d9a/sais_notify-0.0.15.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### \u53d1\u9001\u90ae\u4ef6\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.EMAIL, to=\"\u90ae\u7bb1\uff0c\u591a\u4e2a\u9017\u53f7\u9694\u5f00\", message=\"\u90ae\u4ef6\u6b63\u6587\u5185\u5bb9\", subject=\"\u90ae\u4ef6\u4e3b\u9898\")\n```\n\n### \u53d1\u9001\u77ed\u4fe1\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.SMS, to=\"\u624b\u673a\u53f7\uff0c\u591a\u4e2a\u9017\u53f7\u9694\u5f00\", message=\"\u77ed\u4fe1\u53d8\u91cf\u53c2\u6570\uff0c\u7c7b\u578bjsonstring\", sign_name=\"\u7b7e\u540d\", template_code=\"\u6a21\u677f\u540d\u79f0\")\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        \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.15",
    "project_urls": {
        "repository": "https://github.com/xxx/xxxx"
    },
    "split_keywords": [
        "sais",
        " sais-notify"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "42f0a75544fdaf64c9d800fde674b159098640ac01bd193bd77477dd03d5ce7d",
                "md5": "d9d606c217cfe70a95f94570a650bc0c",
                "sha256": "185194a2218b118bb71c6f076be4ad832741b43d685c75ec342ee80ea7d5f1fc"
            },
            "downloads": -1,
            "filename": "sais_notify-0.0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d9d606c217cfe70a95f94570a650bc0c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8917,
            "upload_time": "2024-10-14T06:05:31",
            "upload_time_iso_8601": "2024-10-14T06:05:31.015676Z",
            "url": "https://files.pythonhosted.org/packages/42/f0/a75544fdaf64c9d800fde674b159098640ac01bd193bd77477dd03d5ce7d/sais_notify-0.0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc0c69c067b4740fe936d0e535081a19bc895f8ab764819a1dacb72ce5977d9a",
                "md5": "cd23c52a6beb74b79626544dbeb647ba",
                "sha256": "2e74af47cf32092a6653a1697088ebb86f84f849226577ca89ba12f069cfe732"
            },
            "downloads": -1,
            "filename": "sais_notify-0.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "cd23c52a6beb74b79626544dbeb647ba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5474,
            "upload_time": "2024-10-14T06:05:32",
            "upload_time_iso_8601": "2024-10-14T06:05:32.550751Z",
            "url": "https://files.pythonhosted.org/packages/fc/0c/69c067b4740fe936d0e535081a19bc895f8ab764819a1dacb72ce5977d9a/sais_notify-0.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-14 06:05:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xxx",
    "github_project": "xxxx",
    "github_not_found": true,
    "lcname": "sais-notify"
}
        
Elapsed time: 0.87121s