Browse Source

Improved token processing method and misc bugfixes

Replace '_err' to '_debug' in the final error report.
Removed redundancy code.
pull/2719/head
Victor Huang 5 years ago
committed by GitHub
parent
commit
5d88ad554f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      notify/cqhttp.sh

25
notify/cqhttp.sh

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#Support for CQHTTP api. Push notification on CoolQ #Support for CQHTTP api. Push notification on CoolQ
#CQHTTP_TOKEN="" Required, QQ application token
#CQHTTP_TOKEN="" Recommended to be not empty, QQ application token
#CQHTTP_USER="" Required, QQ receiver ID #CQHTTP_USER="" Required, QQ receiver ID
#CQHTTP_APIROOT="" Required, CQHTTP Server URL (without slash suffix) #CQHTTP_APIROOT="" Required, CQHTTP Server URL (without slash suffix)
#CQHTTP_CUSTOM_MSGHEAD="" Optional, custom message header #CQHTTP_CUSTOM_MSGHEAD="" Optional, custom message header
@ -17,12 +17,9 @@ cqhttp_send() {
CQHTTP_TOKEN="${CQHTTP_TOKEN:-$(_readaccountconf_mutable CQHTTP_TOKEN)}" CQHTTP_TOKEN="${CQHTTP_TOKEN:-$(_readaccountconf_mutable CQHTTP_TOKEN)}"
if [ -z "$CQHTTP_TOKEN" ]; then if [ -z "$CQHTTP_TOKEN" ]; then
CQHTTP_TOKEN="" CQHTTP_TOKEN=""
_err "You didn't specify a CQHTTP application token yet. If it's empty please pass \"__ACME_SH_TOKEN_EMPTY__\" (without quote)."
return 1
fi
_saveaccountconf_mutable CQHTTP_TOKEN "$CQHTTP_TOKEN"
if [ "$CQHTTP_TOKEN" = "__ACME_SH_TOKEN_EMPTY__" ]; then
CQHTTP_TOKEN=""
_info "You didn't specify a CQHTTP application token yet, which is unsafe. Assuming it to be empty."
else
_saveaccountconf_mutable CQHTTP_TOKEN "$CQHTTP_TOKEN"
fi fi
CQHTTP_USER="${CQHTTP_USER:-$(_readaccountconf_mutable CQHTTP_USER)}" CQHTTP_USER="${CQHTTP_USER:-$(_readaccountconf_mutable CQHTTP_USER)}"
@ -36,15 +33,7 @@ cqhttp_send() {
CQHTTP_APIROOT="${CQHTTP_APIROOT:-$(_readaccountconf_mutable CQHTTP_APIROOT)}" CQHTTP_APIROOT="${CQHTTP_APIROOT:-$(_readaccountconf_mutable CQHTTP_APIROOT)}"
if [ -z "$CQHTTP_APIROOT" ]; then if [ -z "$CQHTTP_APIROOT" ]; then
CQHTTP_APIROOT="" CQHTTP_APIROOT=""
_err "You didn't specify a QQ user yet."
return 1
fi
_saveaccountconf_mutable CQHTTP_APIROOT "$CQHTTP_APIROOT"
CQHTTP_APIROOT="${CQHTTP_APIROOT:-$(_readaccountconf_mutable CQHTTP_APIROOT)}"
if [ -z "$CQHTTP_APIROOT" ]; then
CQHTTP_APIROOT=""
_err "You didn't specify a QQ user yet."
_err "You didn't specify the API root yet."
return 1 return 1
fi fi
_saveaccountconf_mutable CQHTTP_APIROOT "$CQHTTP_APIROOT" _saveaccountconf_mutable CQHTTP_APIROOT "$CQHTTP_APIROOT"
@ -69,7 +58,7 @@ cqhttp_send() {
fi fi
_err "QQ send error." _err "QQ send error."
_err "URL: $_finalUrl"
_err "Response: $response"
_debug "URL" "$_finalUrl"
_debug "Response" "$response"
return 1 return 1
} }
Loading…
Cancel
Save