mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-07 16:34:11 +00:00
Create gchat.sh
add support for gchat webhooks
This commit is contained in:
parent
4c32bc8e22
commit
682828dc7c
35
notify/gchat.sh
Normal file
35
notify/gchat.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#Support Schmoogle Gchat webhooks
|
||||
|
||||
#GCHAT_WEBHOOK_URL=""
|
||||
|
||||
gchat_send() {
|
||||
_subject="$1"
|
||||
_content="$2"
|
||||
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
|
||||
_debug "_statusCode" "$_statusCode"
|
||||
|
||||
GCHAT_WEBHOOK_URL="${GCHAT_WEBHOOK_URL:-$(_readaccountconf_mutable GCHAT_WEBHOOK_URL)}"
|
||||
if [ -z "$GCHAT_WEBHOOK_URL" ]; then
|
||||
GCHAT_WEBHOOK_URL=""
|
||||
_err "You didn't specify a Gchat webhook url. export GCHAT_WEBHOOK_URL=\"https://chat.googleapis.com/v1/spaces/xxxxxxx\""
|
||||
return 1
|
||||
fi
|
||||
_saveaccountconf_mutable GCHAT_WEBHOOK_URL "$GCHAT_WEBHOOK_URL"
|
||||
|
||||
export _H1="Content-Type: application/json"
|
||||
|
||||
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
|
||||
_data="{\"text\": \"$_content\", "
|
||||
|
||||
if _post "$_data" "$GCHAT_WEBHOOK_URL"; then
|
||||
if [ "$response" = "ok" ]; then
|
||||
_info "gchat send success."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
_err "gchat send error."
|
||||
_err "$response"
|
||||
return 1
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user