no message
This commit is contained in:
parent
13757b0aae
commit
e5df7a75f8
@ -29,6 +29,72 @@ class CronController
|
|||||||
|
|
||||||
private $sPull = "y";
|
private $sPull = "y";
|
||||||
|
|
||||||
|
private function lifeToTg($h, $i, $s)
|
||||||
|
{
|
||||||
|
$oHttpTg = new TGHttp();
|
||||||
|
|
||||||
|
if ($h == "08" && $i == "00") {
|
||||||
|
$oArticle = Article::where("status", 1)->get();
|
||||||
|
|
||||||
|
$aMsg = [];
|
||||||
|
foreach ($oArticle as $oArticleRow) {
|
||||||
|
$sMsgR = $this->_lifeToTg($oArticleRow);
|
||||||
|
$aMsg[] = $sMsgR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oHttpTg->send($aMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _lifeToTg($oArticle)
|
||||||
|
{
|
||||||
|
$oHttp = new Http();
|
||||||
|
$oHttp->sToUrl = "https://api.github.com/repos/".$oArticle->user_name."/".$oArticle->project_name;
|
||||||
|
$oHttp->sMethod = "get";
|
||||||
|
$r = $oHttp->send();
|
||||||
|
|
||||||
|
$sMsg = "?";
|
||||||
|
|
||||||
|
if (!$r) {
|
||||||
|
$oHttpTg = new TGHttp();
|
||||||
|
$oHttpTg->send("请求github的api失败??");
|
||||||
|
}
|
||||||
|
|
||||||
|
$aGitHub = json_decode($r, true);
|
||||||
|
|
||||||
|
if (isset($aGitHub["status"]) && $aGitHub["status"] == "404") {
|
||||||
|
$aMsg["msg"] = "嘎了~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
|
||||||
|
$aMsg["article"] = $oArticle;
|
||||||
|
$sMsg = json_encode($aMsg, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
|
return $sMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = str_replace("T", " ", rtrim($aGitHub["updated_at"], "Z")); //updated_at, pushed_at
|
||||||
|
$tmp = strtotime($tmp);
|
||||||
|
$tmpDate = date("Y-m-d H:i:s", $tmp + (8 * 3600));
|
||||||
|
$tmpTime = strtotime($tmpDate);
|
||||||
|
$tmpNowTime = time();
|
||||||
|
$tmpDiff = $tmpNowTime - $tmpTime;
|
||||||
|
$iLastUpdate = ceil($tmpDiff / 60);
|
||||||
|
|
||||||
|
$aGitHubNew = [];
|
||||||
|
$aGitHubNew["⭐️星星"] = $aGitHub["stargazers_count"];
|
||||||
|
$aGitHubNew["♻️最后更新"] = $iLastUpdate."分钟前"; // 替换T为空格并去掉Z
|
||||||
|
$aGitHubNew["forks"] = $aGitHub["forks_count"];
|
||||||
|
$aGitHubNew["watchers"] = $aGitHub["watchers_count"];
|
||||||
|
$aGitHubNew["url"] = $this->urlFormat($aGitHub["html_url"]);
|
||||||
|
|
||||||
|
$sMsg = json_encode($aGitHubNew, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
return $sMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function urlFormat($sUrl)
|
||||||
|
{
|
||||||
|
$sUrlNew = str_replace('/', '$', $sUrl);
|
||||||
|
return $sUrlNew;
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -41,7 +107,7 @@ class CronController
|
|||||||
// $bSendTg = true;
|
// $bSendTg = true;
|
||||||
// $isTest = 0;
|
// $isTest = 0;
|
||||||
|
|
||||||
//test
|
//// test
|
||||||
$aGet = $_GET;
|
$aGet = $_GET;
|
||||||
if (isset($aGet['is_test']) && $aGet['is_test'] == 1) {
|
if (isset($aGet['is_test']) && $aGet['is_test'] == 1) {
|
||||||
$isTest = 1;
|
$isTest = 1;
|
||||||
@ -57,6 +123,11 @@ class CronController
|
|||||||
$iTestId = $aGet["v"];
|
$iTestId = $aGet["v"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//// test
|
||||||
|
$h = "08";
|
||||||
|
$i = "00";
|
||||||
|
|
||||||
|
$this->lifeToTg($h, $i, $s);
|
||||||
|
|
||||||
if (isset($aGet["sSendTg"])) {
|
if (isset($aGet["sSendTg"])) {
|
||||||
$this->sSendTg = $aGet["sSendTg"];
|
$this->sSendTg = $aGet["sSendTg"];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user