no message

This commit is contained in:
hellcat 2025-07-03 19:43:42 +08:00
parent d1f9fa0d30
commit 8932824f1e
5 changed files with 153 additions and 2 deletions

View File

@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api;
use App\Models\BoxCountry as ModelCountry;
final class CountryController
{
// case等于不同的集成方案
public function rand($sCase = "a")
{
if ($sCase == "a") {
$iCountryLimit = rand(4, 8); // 平均6
$iNodeLimit = rand(10, 35); // 平局20多
$iSpeedLimit = rand(5, 30);
}
//test
// $iCountryLimit = 3;
$iNodeCount = $iNodeLimit;
$iSpeed = $iSpeedLimit;
$aCountry = ModelCountry::all()->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;
}
}

View File

@ -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";

13
app/Models/BoxCountry.php Executable file
View File

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class boxCountry extends Model
{
protected $table = 'box_country';
public $timestamps = false;
}

View File

@ -5,9 +5,81 @@ namespace App\Services\TG\Hook\Mod;
//use App\Models\Box as ModelShip;
//use App\Services\TomTool\Http;
use App\Models\BoxGithubTag as GithubTag;
use App\Models\boxCountry as ModelBoxCountry;
class Box extends Base {
public function country_list()
{
$oCountry = ModelBoxCountry::all()->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;

View File

@ -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']);