#tradewind:update notify

This commit is contained in:
tradewind 2021-02-07 19:50:21 +08:00 committed by tradewind
parent 0d496abee4
commit 8105eb79ca
2 changed files with 34 additions and 5 deletions

View File

@ -7,6 +7,7 @@
},
"require": {
"php": ">=7.1.0",
"cloudflare/sdk": "^1.1"
"cloudflare/sdk": "^1.1",
"guzzlehttp/guzzle": "~6.0"
}
}

View File

@ -44,10 +44,17 @@ if (!empty($realIp)) {
try {
$dns->updateRecordDetails($zoneID, $recordId, $details);
$cmd = <<< CMD
curl -s 'https://oapi.dingtalk.com/robot/send?access_token={$globalConfig['dingtalk_token']}' -H 'Content-Type: application/json' -d "{\"msgtype\": \"text\",\"text\": {\"content\": \"$msg\"}}"
CMD;
shell_exec($cmd);
$url = 'https://sc.ftqq.com/' . $globalConfig['serverchan_token'] . '.send';
$client = new \GuzzleHttp\Client();
$client->request('POST', $url, [
'text' => 'IP变更',
'desc' => $msg,
]);
// $cmd = <<< CMD
//curl -s 'https://oapi.dingtalk.com/robot/send?access_token={$globalConfig['dingtalk_token']}' -H 'Content-Type: application/json' -d "{\"msgtype\": \"text\",\"text\": {\"content\": \"$msg\"}}"
//CMD;
// shell_exec($cmd);
logMessage('SUCCESS', $msg);
} catch (Exception $e) {
@ -61,6 +68,27 @@ CMD;
}
function sc_send($text, $desp = '', $key = 'SCU159053T3de1450d55d3b894e39c7a2ecd583984601fce6865119')
{
$postdata = http_build_query(
array(
'text' => $text,
'desp' => $desp
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
return $result = file_get_contents('https://sc.ftqq.com/' . $key . '.send', false, $context);
}
function logMessage($type, $msg = '')
{