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