92 lines
2.1 KiB
PHP
92 lines
2.1 KiB
PHP
<?php
|
||
|
||
namespace App\Services\TG\Hook\Mod;
|
||
|
||
//use App\Models\Hook as ModelHook;
|
||
use App\Models\DoveSite as ModelDoveSite;
|
||
|
||
class Dove extends Base {
|
||
|
||
public function go($aParam, $aData)
|
||
{
|
||
$oDoveSiteCheckedList = ModelDoveSite::where("dove_checked", 1)->get();
|
||
|
||
list(, $sSubCmd) = explode("#", $aData['message']['text'], 2);
|
||
$aData['message']['text'] = "/".$sSubCmd;
|
||
|
||
$aData['dove_token'] = env('dove_token');
|
||
|
||
foreach ($oDoveSiteCheckedList as $row) {
|
||
|
||
$sApiUrl = "https://".$row->www.$row->api_path;
|
||
|
||
$this->oHttp->sMethod = "post";
|
||
$this->oHttp->bIsJson = true;
|
||
$this->oHttp->sToUrl = $sApiUrl;
|
||
$this->oHttp->aData = $aData;
|
||
$r = $this->oHttp->send();
|
||
return $r;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public function set($aParam)
|
||
{
|
||
$iSetValue = $aParam['iSetValue'] ?? 1;
|
||
$sCode = $aParam['aArg'][1];
|
||
|
||
$oDoveSite = ModelDoveSite::where("code", $sCode)->first();
|
||
|
||
if (!$oDoveSite) {
|
||
throw new \Exception("没有这个code");
|
||
}
|
||
|
||
$oDoveSite->dove_checked = $iSetValue;
|
||
|
||
$r = $oDoveSite->save();
|
||
|
||
if (!$r) {
|
||
throw new \Exception("没check上?");
|
||
}
|
||
|
||
$r = $this->now();
|
||
|
||
return $r;
|
||
}
|
||
|
||
public function unsetAll()
|
||
{
|
||
|
||
$r = ModelDoveSite::query()->update(["dove_checked" => 0]);
|
||
|
||
return $r;
|
||
}
|
||
|
||
public function unset($aParam)
|
||
{
|
||
$aParam['iSetValue'] = 0;
|
||
$r = $this->set($aParam);
|
||
|
||
return $r;
|
||
}
|
||
|
||
public function now()
|
||
{
|
||
$aDoveSiteNow = ModelDoveSite::where("dove_checked", 1)->get()->toArray();
|
||
|
||
if ($aDoveSiteNow) {
|
||
$r = "";
|
||
foreach ($aDoveSiteNow as $row) {
|
||
$r .= "\n";
|
||
$r .= $row['code']."::".$row['www']."::".$row['class'];
|
||
}
|
||
} else {
|
||
$r = "没有";
|
||
}
|
||
|
||
return $r;
|
||
}
|
||
|
||
}
|