12345678910111213141516171819202122232425262728293031323334353637383940 |
- """
- @author: luojunhui
- """
- import json
- import requests
- def bot(title, detail, mention=True):
- """
- 机器人
- """
- title_obj = {
- "content": "{}<at id=all></at>\n".format(title) if mention else "{}\n".format(title),
- "tag": "lark_md",
- }
- head_title = "【重点关注】" if mention else "【普通通知】"
- url = "https://open.feishu.cn/open-apis/bot/v2/hook/f32c0456-847f-41f3-97db-33fcc1616bcd"
- headers = {"Content-Type": "application/json"}
- payload = {
- "msg_type": "interactive",
- "card": {
- "elements": [
- {
- "tag": "div",
- "text": title_obj,
- },
- {
- "tag": "div",
- "text": {
- "content": json.dumps(
- detail, ensure_ascii=False, indent=4
- ),
- "tag": "lark_md",
- },
- },
- ],
- "header": {"title": {"content": head_title, "tag": "plain_text"}},
- },
- }
- requests.request("POST", url=url, headers=headers, data=json.dumps(payload), timeout=10)
|