no message
This commit is contained in:
parent
0fc97233b5
commit
118b1a8ea5
@ -28,6 +28,16 @@ final class HookController
|
|||||||
$aData['chatId'] = $aUpdate["message"]["chat"]["id"];
|
$aData['chatId'] = $aUpdate["message"]["chat"]["id"];
|
||||||
$aData['fromId'] = $aUpdate["message"]["from"]["id"];
|
$aData['fromId'] = $aUpdate["message"]["from"]["id"];
|
||||||
|
|
||||||
|
$mSendType = false;
|
||||||
|
|
||||||
|
if (isset($aUpdate["is_dove"])) {
|
||||||
|
$mSendType = "dove";
|
||||||
|
}
|
||||||
|
|
||||||
|
// tomd($mSendType, 1);
|
||||||
|
|
||||||
|
// $mSendType = $aUpdate[]
|
||||||
|
|
||||||
if (!isset($aUpdate["message"]["text"])) {
|
if (!isset($aUpdate["message"]["text"])) {
|
||||||
throw new \Exception("?");
|
throw new \Exception("?");
|
||||||
}
|
}
|
||||||
@ -71,10 +81,10 @@ final class HookController
|
|||||||
// 返回可以是数组
|
// 返回可以是数组
|
||||||
if (is_array($r)) {
|
if (is_array($r)) {
|
||||||
foreach ($r as $row) {
|
foreach ($r as $row) {
|
||||||
$oTGHttp->sendToTG($row);
|
$oTGHttp->sendToTG($row, $mSendType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$oTGHttp->sendToTG($r);
|
$oTGHttp->sendToTG($r, $mSendType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Http::response(200, 'ok');
|
Http::response(200, 'ok');
|
||||||
@ -87,7 +97,7 @@ final class HookController
|
|||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$sMessage = "错误(line:".$e->getLine()."): " . $e->getMessage();
|
$sMessage = "错误(line:".$e->getLine()."): " . $e->getMessage();
|
||||||
|
|
||||||
$oTGHttp->sendToTG($sMessage);
|
$oTGHttp->sendToTG($sMessage, $mSendType);
|
||||||
|
|
||||||
Http::response(200, 'error');
|
Http::response(200, 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,7 @@ class Cmd extends Base {
|
|||||||
'测试cron' => "test#cron_i 01",
|
'测试cron' => "test#cron_i 01",
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->oTGHttp->sendToTG(json_encode($aCmdList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
return $this->toJson($aCmdList);
|
||||||
|
|
||||||
$this->oHttp::response(200, 'ok');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,15 +13,23 @@ class Http {
|
|||||||
$this->sApiChatId = env('telegram_chatid');
|
$this->sApiChatId = env('telegram_chatid');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendToTG($sMsg)
|
public function sendToTG($sMsg, $mType = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (env('is_loc') == true) {
|
if ($mType == "dove") {
|
||||||
|
|
||||||
|
echo $sMsg;
|
||||||
|
|
||||||
|
} else if (env('is_loc') == true) {
|
||||||
|
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
echo($sMsg);
|
echo($sMsg);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
|
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
|
||||||
file_get_contents($url);
|
file_get_contents($url);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user