Python: 企业微信机器人Webhook消息推送脚本

便于配置定时消息推送

import requests

webhook_url = 'https://企业微信机器人webhook链接'

def send_wx_msg(msg, at_all=True):
    # 判断是否艾特全体,默认开启
    notify_list = ['@all'] if at_all else []
    # 请求体
    content = {
        "msgtype": "text",
        "text": {
            "content": msg,
            "mentioned_mobile_list": notify_list,
        }
    }
    response = requests.post(webhook_url, json=content)
    # 调试输出
    print(response.status_code, response.json())

# 调用示例
send_wx_msg('测试消息')
暂无评论

发送评论 编辑评论


				
上一篇
下一篇