no message
This commit is contained in:
parent
f7947cee9d
commit
8e2a57a5d1
@ -35,6 +35,12 @@ final class HookController
|
||||
|
||||
$sText = $aUpdate["message"]["text"];
|
||||
|
||||
if (isset($sText["is_dove"])) {
|
||||
$sSendType = "dove";
|
||||
} else {
|
||||
$sSendType = false;
|
||||
}
|
||||
|
||||
// test
|
||||
// $sText = "\\//Article#List ni__aaa__bbb 111 222";
|
||||
// $sText = "///\\\SaleCode#SetRate__zzxx 2";
|
||||
@ -72,10 +78,10 @@ final class HookController
|
||||
// 返回可以是数组
|
||||
if (is_array($r)) {
|
||||
foreach ($r as $row) {
|
||||
$oTGHttp->sendToTG($row);
|
||||
$oTGHttp->sendToTG($row, $sSendType);
|
||||
}
|
||||
} else {
|
||||
$oTGHttp->sendToTG($r);
|
||||
$oTGHttp->sendToTG($r, $sSendType);
|
||||
}
|
||||
|
||||
Http::response(200, 'ok');
|
||||
@ -88,7 +94,7 @@ final class HookController
|
||||
} catch (\Throwable $e) {
|
||||
$sMessage = "错误(line:".$e->getLine()."): " . $e->getMessage();
|
||||
|
||||
$oTGHttp->sendToTG($sMessage);
|
||||
$oTGHttp->sendToTG($sMessage, $sSendType);
|
||||
|
||||
Http::response(200, 'error');
|
||||
}
|
||||
|
||||
@ -13,15 +13,27 @@ class Http {
|
||||
$this->sApiChatId = env('telegram_chatid');
|
||||
}
|
||||
|
||||
public function sendToTG($sMsg)
|
||||
public function sendToTG($sMsg, $mType = false)
|
||||
{
|
||||
|
||||
if (env('is_loc') === true) {
|
||||
echo "<pre>";
|
||||
echo($sMsg);
|
||||
if ($mType == "dove") {
|
||||
|
||||
if (env("is_loc") == true) {
|
||||
echo "<pre>";
|
||||
}
|
||||
|
||||
echo $sMsg;
|
||||
|
||||
} else {
|
||||
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
|
||||
file_get_contents($url);
|
||||
|
||||
if (env("is_loc") == true) {
|
||||
echo "<pre>";
|
||||
echo($sMsg);
|
||||
} else {
|
||||
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
|
||||
file_get_contents($url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user