From 8932824f1e8abcbb14b761be883d37be2b3ddef5 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Thu, 3 Jul 2025 19:43:42 +0800 Subject: [PATCH] no message --- .../Controllers/Api/CountryController.php | 62 ++++++++++++++++ app/Http/Controllers/SakaiController.php | 3 + app/Models/BoxCountry.php | 13 ++++ app/Services/TG/Hook/Mod/Box.php | 72 +++++++++++++++++++ routes/web.php | 5 +- 5 files changed, 153 insertions(+), 2 deletions(-) create mode 100755 app/Http/Controllers/Api/CountryController.php create mode 100755 app/Models/BoxCountry.php diff --git a/app/Http/Controllers/Api/CountryController.php b/app/Http/Controllers/Api/CountryController.php new file mode 100755 index 00000000..43698444 --- /dev/null +++ b/app/Http/Controllers/Api/CountryController.php @@ -0,0 +1,62 @@ +toArray(); + + shuffle($aCountry); + + $i = 1; + $aRandCountry = []; + foreach ($aCountry as $aCountryRow) { + + if (in_array($aCountryRow["name"], $aRandCountry)) { + continue; + } + + $aRandCountry[] = $aCountryRow["name"]; + + if ($i >= $iCountryLimit) { + break; + } else { + $i++; + } + + } + + $aData["country"] = $aRandCountry; + $aData["nodeCount"] = $iNodeCount; + $aData["speed"] = $iSpeed; +// $aData["str"] = "本次更新共".$iNodeLimit."个可用节点,"; + +// tomd($iSpeed, 1); +// tomd($aData, 1); + + echo json_encode($aData); + exit; + } + +} diff --git a/app/Http/Controllers/SakaiController.php b/app/Http/Controllers/SakaiController.php index 8776d11b..8bae2a09 100755 --- a/app/Http/Controllers/SakaiController.php +++ b/app/Http/Controllers/SakaiController.php @@ -366,6 +366,9 @@ class SakaiController $s = "/box#github_tag_rand__b 3"; + $s = "/box#country_list"; + + $s = "/box#country_add 冰岛"; // $s = "toWait 333333"; // $s = "no 2"; diff --git a/app/Models/BoxCountry.php b/app/Models/BoxCountry.php new file mode 100755 index 00000000..032f1b05 --- /dev/null +++ b/app/Models/BoxCountry.php @@ -0,0 +1,13 @@ +toArray(); + + return $this->toJson($oCountry); + } + + public function country_add($aParam) + { + $sName = $aParam["aArg"][1] ?? false; + + if (!$sName) { + return "需要有arg[1],name。"; + } + + $oCountry = new ModelBoxCountry(); + $oCountry->name = $sName; + $oCountry->save(); + + return $this->toJson($oCountry); + } + + public function country_set($aParam) + { + $iId = $aParam["aOption"][1] ?? false; + $sField = $aParam["aArg"][1] ?? false; + $sValue = $aParam["aArg"][2] ?? false; + + if (!$iId) { + return "需要option[1],id。"; + } + + if (!$sField) { + return "需要arg[1],field。"; + } + + if (!$sValue) { + return "需要arg[2],value。"; + } + + $oCountry = ModelBoxCountry::find($iId); + + if (!$oCountry) { + return "没找到"; + } + + $oCountry->$sField = $sValue; + $oCountry->save(); + + return $this->toJson($oCountry); + } + + public function country_del($aParam) + { + $iId = $aParam["aArg"][1] ?? false; + + if (!$iId) { + return "需要arg[1],id。"; + } + + $oCountry = ModelBoxCountry::find($iId); + + if (!$oCountry) { + return "没找到"; + } + + $r = $oCountry->delete(); + + return $r; + } + public function github_tag_rand($aParam) { $sType = $aParam["aOption"][1] ?? false; diff --git a/routes/web.php b/routes/web.php index b370492d..0653bc26 100755 --- a/routes/web.php +++ b/routes/web.php @@ -12,13 +12,14 @@ use App\Http\Controllers\CronController; use App\Http\Controllers\Api\ShipController; //use App\Http\Controllers\Api\GithubController; use App\Http\Controllers\Api\TG\HookController; +use App\Http\Controllers\Api\CountryController; //Route::get('/', [ArticleListController::class, 'fn'])->middleware('test'); +Route::get('/api/freenode/country/rand/{case?}', [CountryController::class, 'rand']); + Route::get('/api/ship/get/{shipCode}/{clientClass}/{clientCode?}', [ShipController::class, 'getShipByCode']); - - Route::get('/cron', [CronController::class, 'index']); Route::get('/test/hook', [SakaiController::class, 'hook']);