30 lines
		
	
	
		
			628 B
		
	
	
	
		
			Python
		
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			628 B
		
	
	
	
		
			Python
		
	
	
#!/usr/bin/python
 | 
						|
# coding=utf-8
 | 
						|
 | 
						|
import requests
 | 
						|
import json
 | 
						|
 | 
						|
 | 
						|
def wechat_alert(message, hook_url, at_people_list=[]):
 | 
						|
    pass
 | 
						|
    webhook = hook_url
 | 
						|
    header = {
 | 
						|
        "Content-Type": "application/json",
 | 
						|
        "Charset": "UTF-8"
 | 
						|
    }
 | 
						|
 | 
						|
    print(message)
 | 
						|
    msg = {
 | 
						|
        "msgtype": "text",
 | 
						|
        "text": {
 | 
						|
            "content": message,
 | 
						|
            "mentioned_mobile_list": at_people_list,
 | 
						|
        },
 | 
						|
    }
 | 
						|
    message_json = json.dumps(msg)
 | 
						|
    info = requests.post(url=webhook, data=message_json, headers=header)
 | 
						|
    print(info.text)
 | 
						|
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
    wechat_alert("测试机器人消息发送") |