2022-05-09 04:40:36 +02:00
|
|
|
#!/usr/bin/env sh
|
2022-05-05 14:20:29 +02:00
|
|
|
|
|
|
|
#Support CallMeBot Whatsapp webhooks
|
|
|
|
|
2022-05-07 16:22:33 +02:00
|
|
|
#CALLMEBOT_YOUR_PHONE_NO=""
|
|
|
|
#CALLMEBOT_API_KEY=""
|
2022-05-05 14:20:29 +02:00
|
|
|
|
2022-05-05 23:12:52 +02:00
|
|
|
callmebotWhatsApp_send() {
|
2022-05-05 14:20:29 +02:00
|
|
|
_subject="$1"
|
|
|
|
_content="$2"
|
|
|
|
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
|
|
|
|
_debug "_statusCode" "$_statusCode"
|
|
|
|
|
2022-05-07 16:22:33 +02:00
|
|
|
CALLMEBOT_YOUR_PHONE_NO="${CALLMEBOT_YOUR_PHONE_NO:-$(_readaccountconf_mutable CALLMEBOT_YOUR_PHONE_NO)}"
|
|
|
|
if [ -z "$CALLMEBOT_YOUR_PHONE_NO" ]; then
|
|
|
|
CALLMEBOT_YOUR_PHONE_NO=""
|
|
|
|
_err "You didn't specify a Slack webhook url CALLMEBOT_YOUR_PHONE_NO yet."
|
2022-05-05 14:20:29 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2022-05-07 16:22:33 +02:00
|
|
|
_saveaccountconf_mutable CALLMEBOT_YOUR_PHONE_NO "$CALLMEBOT_YOUR_PHONE_NO"
|
2022-05-05 14:20:29 +02:00
|
|
|
|
2022-05-07 16:22:33 +02:00
|
|
|
CALLMEBOT_API_KEY="${CALLMEBOT_API_KEY:-$(_readaccountconf_mutable CALLMEBOT_API_KEY)}"
|
2022-05-09 04:43:23 +02:00
|
|
|
if [ "$CALLMEBOT_API_KEY" ]; then
|
2022-05-07 16:22:33 +02:00
|
|
|
_saveaccountconf_mutable CALLMEBOT_API_KEY "$CALLMEBOT_API_KEY"
|
2022-05-05 14:20:29 +02:00
|
|
|
fi
|
2022-05-07 03:40:42 +02:00
|
|
|
|
2022-05-05 23:12:52 +02:00
|
|
|
_waUrl="https://api.callmebot.com/whatsapp.php"
|
2022-05-07 03:40:42 +02:00
|
|
|
|
2022-05-07 16:22:33 +02:00
|
|
|
_Phone_No="$(printf "%s" "$CALLMEBOT_YOUR_PHONE_NO" | _url_encode)"
|
|
|
|
_apikey="$(printf "%s" "$CALLMEBOT_API_KEY" | _url_encode)"
|
2022-05-09 13:03:26 +02:00
|
|
|
_message="$(printf "*%s*\\n%s" "$_subject" "$_content" | _url_encode)"
|
2022-05-07 03:40:42 +02:00
|
|
|
|
2022-05-05 23:12:52 +02:00
|
|
|
_finalUrl="$_waUrl?phone=$_Phone_No&apikey=$_apikey&text=$_message"
|
|
|
|
response="$(_get "$_finalUrl")"
|
|
|
|
|
|
|
|
if [ "$?" = "0" ] && _contains ".<p><b>Message queued.</b> You will receive it in a few seconds."; then
|
|
|
|
_info "wa send success."
|
|
|
|
return 0
|
2022-05-05 14:20:29 +02:00
|
|
|
fi
|
|
|
|
_err "wa send error."
|
2022-05-05 23:12:52 +02:00
|
|
|
_debug "URL" "$_finalUrl"
|
|
|
|
_debug "Response" "$response"
|
2022-05-05 14:20:29 +02:00
|
|
|
return 1
|
2022-05-07 03:40:42 +02:00
|
|
|
}
|