fuc/src/Services/Tg/Http.php
2025-07-27 12:16:12 +08:00

89 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
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 {
public $sApiToken;
public $sApiChatId;
function __construct()
{
$this->sApiToken = Config::obtain('telegram_token');
$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 = [])
{
if (isset($aUpdate["shell"]) && $aUpdate["shell"] == "cmd") {
echo $sMsg;
} else if (isset($aUpdate["is_dove"]) && $aUpdate["is_dove"] == true) {
echo $sMsg;
} else {
(new Telegram())->send(0, $sMsg);
}
}
}