mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
This commit is contained in:
parent
3ec495225f
commit
5698bec621
2
acme.sh
2
acme.sh
@ -6070,7 +6070,7 @@ _send_notify() {
|
||||
_set_notify_hook() {
|
||||
_nhooks="$1"
|
||||
|
||||
_test_subject="Hello, this is notification from $PROJECT_NAME"
|
||||
_test_subject="Hello, this is a notification from $PROJECT_NAME"
|
||||
_test_content="If you receive this message, your notification works."
|
||||
|
||||
_send_notify "$_test_subject" "$_test_content" "$_nhooks" 0
|
||||
|
69
notify/dingtalk.sh
Normal file
69
notify/dingtalk.sh
Normal file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#Support dingtalk webhooks api
|
||||
|
||||
#DINGTALK_WEBHOOK="xxxx"
|
||||
|
||||
#optional
|
||||
#DINGTALK_KEYWORD="yyyy"
|
||||
|
||||
#DINGTALK_SIGNING_KEY="SEC08ffdbd403cbc3fc8a65xxxxxxxxxxxxxxxxxxxx"
|
||||
|
||||
# subject content statusCode
|
||||
dingtalk_send() {
|
||||
_subject="$1"
|
||||
_content="$2"
|
||||
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
|
||||
_debug "_subject" "$_subject"
|
||||
_debug "_content" "$_content"
|
||||
_debug "_statusCode" "$_statusCode"
|
||||
|
||||
DINGTALK_WEBHOOK="${DINGTALK_WEBHOOK:-$(_readaccountconf_mutable DINGTALK_WEBHOOK)}"
|
||||
if [ -z "$DINGTALK_WEBHOOK" ]; then
|
||||
DINGTALK_WEBHOOK=""
|
||||
_err "You didn't specify a dingtalk webhooks DINGTALK_WEBHOOK yet."
|
||||
_err "You can get yours from https://dingtalk.com"
|
||||
return 1
|
||||
fi
|
||||
_saveaccountconf_mutable DINGTALK_WEBHOOK "$DINGTALK_WEBHOOK"
|
||||
|
||||
DINGTALK_KEYWORD="${DINGTALK_KEYWORD:-$(_readaccountconf_mutable DINGTALK_KEYWORD)}"
|
||||
if [ "$DINGTALK_KEYWORD" ]; then
|
||||
_saveaccountconf_mutable DINGTALK_KEYWORD "$DINGTALK_KEYWORD"
|
||||
fi
|
||||
|
||||
# DINGTALK_SIGNING_KEY="${DINGTALK_SIGNING_KEY:-$(_readaccountconf_mutable DINGTALK_SIGNING_KEY)}"
|
||||
# if [ -z "$DINGTALK_SIGNING_KEY" ]; then
|
||||
# DINGTALK_SIGNING_KEY="value1"
|
||||
# _info "The DINGTALK_SIGNING_KEY is not set, so use the default value1 as key."
|
||||
# elif ! _hasfield "$_IFTTT_AVAIL_MSG_KEYS" "$DINGTALK_SIGNING_KEY"; then
|
||||
# _err "The DINGTALK_SIGNING_KEY \"$DINGTALK_SIGNING_KEY\" is not available, should be one of $_IFTTT_AVAIL_MSG_KEYS"
|
||||
# DINGTALK_SIGNING_KEY=""
|
||||
# return 1
|
||||
# else
|
||||
# _saveaccountconf_mutable DINGTALK_SIGNING_KEY "$DINGTALK_SIGNING_KEY"
|
||||
# fi
|
||||
|
||||
# if [ "$DINGTALK_SIGNING_KEY" = "$IFTTT_CONTENT_KEY" ]; then
|
||||
# DINGTALK_SIGNING_KEY=""
|
||||
# IFTTT_CONTENT_KEY=""
|
||||
# _err "The DINGTALK_SIGNING_KEY must not be same as IFTTT_CONTENT_KEY."
|
||||
# return 1
|
||||
# fi
|
||||
|
||||
_content=$(echo "$_content" | _json_encode)
|
||||
_subject=$(echo "$_subject" | _json_encode)
|
||||
_data="{\"msgtype\": \"text\", \"text\": {\"content\": \"[$DINGTALK_KEYWORD]\n$_subject\n$_content\"}}"
|
||||
|
||||
response="$(_post "$_data" "$DINGTALK_WEBHOOK" "" "POST" "application/json")"
|
||||
|
||||
if [ "$?" = "0" ] && _contains "$response" "errmsg\":\"ok"; then
|
||||
_info "dingtalk webhooks event fired success."
|
||||
return 0
|
||||
fi
|
||||
|
||||
_err "dingtalk webhooks event fired error."
|
||||
_err "$response"
|
||||
return 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user