no message
This commit is contained in:
1 parent
20ee43b972
commit
403fa43d44
15 files changed
+1288
-93
No files matched your search
+50
-27
@@ -4,6 +4,7 @@ namespace App\Services\Tg;
|
||||
use App\Models\Config;
|
||||
use App\Services\IM\Telegram;
|
||||
use App\Services\Tg\Http;
|
||||
use App\Services\TomTool\Http as TomHttp;
|
||||
|
||||
class Http {
|
||||
|
||||
@@ -16,6 +17,55 @@ class Http {
|
||||
$this->sApiChatId = Config::obtain('telegram_chatid');
|
||||
}
|
||||
|
||||
public function send($sMsg = "msg空", $aUpdate = [])
|
||||
{
|
||||
|
||||
$bSendTg = true;
|
||||
|
||||
$sShell = $aUpdate["shell"] ?? false;
|
||||
$bIsDove = $aUpdate["is_dove"] ?? false;
|
||||
|
||||
if ($sShell == "cmd") {
|
||||
$bSendTg = false;
|
||||
}
|
||||
|
||||
if ($bIsDove == true) {
|
||||
$bSendTg = false;
|
||||
}
|
||||
|
||||
if ($_ENV['is_loc'] == true) {
|
||||
$bSendTg = false;
|
||||
}
|
||||
|
||||
if (is_array($sMsg)) {
|
||||
foreach ($sMsg as $sMsgRow) {
|
||||
if ($bSendTg) {
|
||||
$this->sendTg($sMsgRow);
|
||||
} else {
|
||||
echo $sMsgRow;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($bSendTg) {
|
||||
$this->sendTg($sMsg);
|
||||
} else {
|
||||
echo $sMsg;
|
||||
}
|
||||
}
|
||||
|
||||
if ($bSendTg) {
|
||||
TomHttp::response(200);
|
||||
} else {
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function sendTg($sMsg)
|
||||
{
|
||||
(new Telegram())->send(0, $sMsg);
|
||||
}
|
||||
|
||||
public function sendToTG($sMsg = "没有msg?", $aUpdate = [])
|
||||
{
|
||||
|
||||
@@ -29,37 +79,10 @@ class Http {
|
||||
|
||||
} else {
|
||||
|
||||
// $oHttp = new Http();
|
||||
// $oHttp->sMethod = "post";
|
||||
// $oHttp->sToUrl = "https://api.telegram.org/bot$this->sApiToken/sendMessage";
|
||||
// $oHttp->bIsJson = true;
|
||||
// $oHttp->aData = [
|
||||
// "chat_id" => $this->sApiChatId,
|
||||
// "text" => $sMsg
|
||||
// ];
|
||||
//
|
||||
// $oHttp->send();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(new Telegram())->send(0, $sMsg);
|
||||
|
||||
}
|
||||
|
||||
// if ($_ENV['is_loc'] === true) {
|
||||
// echo "<pre>";
|
||||
// echo($sMsg);
|
||||
// } else {
|
||||
//
|
||||
// (new Telegram())->send(0, $sMsg);
|
||||
//
|
||||
//// $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
|
||||
//// file_get_contents($url);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user