msgtype
:消息類型,能夠根據本身的使用場景選擇合適的消息類型,如text文本、link鏈接、markdown等;atMobiles
:自定義機器人發送消息時,能夠經過手機號碼指定「被@人列表」,在「被@人列表」裏面的人員收到該消息時,會有@消息提醒;isAtAll
:bool類型,true爲@全部人,不然爲false;import requests import json class DingTalk_Base: def __init__(self): self.__headers = {'Content-Type': 'application/json;charset=utf-8'} self.url = '' def send_msg(self,text): json_text = { "msgtype": "text", "text": { "content": text }, "at": { "atMobiles": [ "" ], "isAtAll": False } } return requests.post(self.url, json.dumps(json_text), headers=self.__headers).content class DingTalk_Disaster(DingTalk_Base): def __init__(self): super().__init__() # 填寫機器人的url self.url = '' if __name__ == '__main__': ding = DingTalk_Disaster() ding.send_msg('')
參考:https://www.9xkd.com/user/plan-view.html?id=4213850024html