#!/bin/bash
#===================================================================
# Filename   : group_chatbot_xibei.sh
# Function   : 
# Usage      : 
# Author     : Manford Fan
# Date       : 2023-05-12 08:59
# Version    : Version 0.1
# Disclaimer : The author is NOT responsible for any loss caused
#              by the user's own operations.
# And More   : If you find there are some bugs in this script
#              Or you have better ideas, please do contact me
#              via E-mail -- mffan0922@163.com
#===================================================================

function sendMsg() {

    # 个人测试
    # curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ddea3f5f-fbfc-4c21-994a-71e9fc50e4ef' \
    #  -H 'Content-Type: application/json' \
    #  -d '
    #  {
    #     "msgtype": "markdown",
    #     "markdown": {
    #         "content": "**'"$alarmTitle"'**\n
    #         > <font color=\"warning\">'"$alarmInfo"'</font>"
    #     }
    #  }' > /dev/null 2>&1

    # 群hook
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5c5f18f1-8494-4f42-b7f1-9ef7295b0578' \
     -H 'Content-Type: application/json' \
     -d '
     {
        "msgtype": "markdown",
        "markdown": {
            "content": "**'"$alarmTitle"'**\n
            > <font color=\"warning\">'"$alarmInfo"'</font>"
        }
     }' > /dev/null 2>&1
}


time_opt=$1
alarmTitle="周报提醒"

if [[ $time_opt == '1' ]]; then
    alarmInfo='周四了，请各位及时填写周报~~'
elif [[ $time_opt == '2' ]]; then
    alarmInfo='记得写周报，记得写周报，记得写周报~~'
else
    :
fi

sendMsg $alarmTitle $alarmInfo
