73 lines
2.2 KiB
PHP
73 lines
2.2 KiB
PHP
<?php
|
||
|
||
namespace App\Services\Tg\Hook\Mod;
|
||
|
||
use App\Models\Node as ModelNode;
|
||
use App\Services\Tg\Hook\Dog;
|
||
use App\Services\TomTool\Http;
|
||
|
||
class Node extends Base {
|
||
|
||
private $oDog;
|
||
|
||
public function __construct($aUpdate)
|
||
{
|
||
|
||
$this->oDog = new Dog(new ModelNode());
|
||
$this->oDog->_setDogName("node"); // 必须,me用,正常就是类名,只不过后期没准改名,所以就这里写死
|
||
// $this->oDog->_setPrimaryKey("code"); // 可选,默认id
|
||
// $this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
|
||
$this->oDog->_setJsonField(["custom_config", "dynamic_rate_config"]);
|
||
$this->oDog->_setHideField(["gfw_block", "dynamic_rate_type", "dynamic_rate_config", "password", "online_user_date_last"]);
|
||
$this->oDog->_setInFormat(["node_bandwidth_limit", "node_bandwidth"]);
|
||
$this->oDog->_setOutFormat([
|
||
"node_heartbeat" => "date",
|
||
"node_bandwidth_limit" => "gb",
|
||
"node_bandwidth" => "gb"
|
||
]);
|
||
}
|
||
|
||
public function __call($sName, $aArg)
|
||
{
|
||
|
||
return $this->oDog->$sName($aArg[0]);
|
||
|
||
}
|
||
|
||
public function Clone($aParam)
|
||
{
|
||
|
||
// list(, $iNodeId) = explode(" ", $sText, 2);
|
||
|
||
$iNodeId = $aParam['aArg'][1];
|
||
|
||
$oHttp = new Http();
|
||
|
||
$oHttp->sMethod = "post";
|
||
$oHttp->sToUrl = $_ENV['baseUrl']."/api/tg/node/".$iNodeId."/copy";
|
||
$oHttp->bIsJson = true;
|
||
$oHttp->aData = [
|
||
'chatId' => $aParam['aOther']['chatId'],
|
||
'fromId' => $aParam['aOther']['fromId']
|
||
];
|
||
|
||
$r = @json_decode($oHttp->send(), true);
|
||
|
||
if ($r["ret"] == 1) {
|
||
// $sMessage = "成功";
|
||
} else {
|
||
$sMessage = "失败";
|
||
return $sMessage;
|
||
}
|
||
|
||
$id = ModelNode::where("type", 1)->orderBy("id", "desc")->first()?->id;
|
||
|
||
$aParam = [];
|
||
$aParam["aArg"][1] = $id;
|
||
|
||
return $this->find($aParam);
|
||
|
||
}
|
||
|
||
}
|