qwmsgios() {
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2fcce817-0f66-4552-bd75-9ee55c690635' \
       -H 'Content-Type: application/json' \
       -d @- <<EOF
       {
            "msgtype": "text",
            "text": {
                "content": "IOS TestFlight上传完成\n构建信息: '$1'\n分支: '$2'"
            }
       }
EOF
}

qwmsg() {
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2fcce817-0f66-4552-bd75-9ee55c690635' \
       -H 'Content-Type: application/json' \
       -d @- <<EOF
       {
            "msgtype": "text",
            "text": {
                "content": "$1"
            }
       }
EOF
}

qwmsguat() {
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2fcce817-0f66-4552-bd75-9ee55c690635' \
       -H 'Content-Type: application/json' \
       -d '
       {
            "msgtype": "text",
            "text": {
                "content": "请注意! 已发布到uat环境"
            }
       }'
}

sendFileToQW() {
    echo $1
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2fcce817-0f66-4552-bd75-9ee55c690635' \
       -H 'Content-Type: application/json' \
       -d @- <<EOF
                 {
                      "msgtype": "file",
                      "file": {
                          "media_id": "$1"
                      }
                 }
EOF
}

sendNewsToQW() {
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2fcce817-0f66-4552-bd75-9ee55c690635' \
       -H 'Content-Type: application/json' \
       -d @- <<EOF
                 {
                     "msgtype": "template_card",
                     "template_card": {
                         "card_type": "news_notice",
                         "main_title": {
                             "title": "欢迎使用CRM",
                             "desc": "打包完成"
                         },
                         "card_image": {
                             "url": "$4"
                         },
                         "horizontal_content_list": [
                            {
                                "keyname":"分支",
                                "value":"$2"
                            },
                            {
                                "keyname":"构建信息",
                                "value":"$3"
                            }
                         ],
                         "jump_list": [
                             {
                                 "type": 1,
                                 "url": "$1",
                                 "title": "APP下载"
                             }
                         ],
                         "card_action":{
                            "type":1,
                            "url":"$3"
                         }
                     }
                 }
EOF
}

sendNewsToQWOnlyDownLoad() {
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2fcce817-0f66-4552-bd75-9ee55c690635' \
       -H 'Content-Type: application/json' \
       -d @- <<EOF
                {
                    "msgtype": "news",
                    "news" : {
                        "articles" : [
                            {
                                "title" : "欢迎使用CRM",
                                "description" : "分支：$2\n构建信息：$3\n资源类型：$4\n点击下载",
                                "url" : "$1",
                                "picurl" : "http://minio-sit.sunda.top/devplatform/upload/20231222/4369df9a7b84e81787d04a9e40a11e14.png"
                            }
                        ]
                   }
                 }
EOF
}

handle_error() {
    echo "An error occurred. Exiting."
    exit_status=$?
    echo $exit_status
}