Skip to content

Commit

Permalink
0.7.4 新增 markdown 消息推送(waditu#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
zengbin93 committed Aug 10, 2021
1 parent a808d4f commit 928b7c9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions czsc/utils/qywx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ def push_text(content: str, key: str) -> None:
except:
print(f"{data} - 文本消息推送失败")


def push_markdown(content: str, key: str) -> None:
"""推送 Markdown 消息到企业微信群
API介绍: https://work.weixin.qq.com/api/doc/90000/90136/91770
:param content: Markdown 内容
:param key: 企业微信群聊机器人的key
:return: None
"""
api_send = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={}".format(key)
data = {"msgtype": "markdown", "markdown": {"content": content}}
try:
response = requests.post(api_send, json=data)
assert response.json()['errmsg'] == 'ok'
except:
print(f"{data} - Markdown 消息推送失败")


def push_file(file: str, key: str):
"""推送文件到企业微信群聊
Expand Down

0 comments on commit 928b7c9

Please sign in to comment.