no message

This commit is contained in:
hellcat 2026-01-17 12:57:57 +08:00
parent dec2fd03ea
commit 2837f37d8c
8 changed files with 473 additions and 1 deletions

24
app/Models/CacheTg.php Executable file
View File

@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ArticleCache extends Model
{
protected $table = 'article_cache';
public $timestamps = false;
// public static function _listKey()
// {
// $aSelf = self::all()->toArray();
//
// foreach ($aSelf as &$aSelfRow) {
// unset($aSelfRow["content"]);
// }
//
// return $aSelf;
// }
}

24
app/Models/CacheTgTime.php Executable file
View File

@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ArticleCacheTime extends Model
{
protected $table = 'article_cache_time';
public $timestamps = false;
// public static function _listKey()
// {
// $aSelf = self::all()->toArray();
//
// foreach ($aSelf as &$aSelfRow) {
// unset($aSelfRow["content"]);
// }
//
// return $aSelf;
// }
}

68
app/Services/CacheTg.php Executable file
View File

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace App\Services;
use App\Models\BoxCountry as ModelCountry;
final class Country
{
// case等于不同的集成方案
public function rand($sCase = "a")
{
if ($sCase == "a") {
$iCountryLimit = rand(5, 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."个可用节点,";
return $aData;
//
// echo json_encode($aData);
// exit;
}
public function strGithub($randData)
{
$str = date('Y年m月d日').",本次更新共".$randData["nodeCount"]."个可用节点,最高速度".$randData["speed"]."M/S。覆盖".implode("", $randData["country"])."等多个区域。";
return $str;
}
}

View File

@ -441,6 +441,17 @@ class Dog extends Mod\Base {
return $iLimit;
}
public function last()
{
$iLastId = $this->oModelSelf->orderBy("id", "desc")->first()?->id;
$aParam = [];
$aParam["aOption"][1] = "id";
$aParam["aArg"][1] = $iLastId;
return $this->find($aParam);
}
public function find($aParam)
{
$sField = $aParam["aOption"][1] ?? $this->sPrimaryKey;

View File

@ -11,7 +11,7 @@ use App\Services\Article\Cmd as ServiceArticleCmd;
use App\Services\TomTool\Flow;
use App\Services\TomTool\ThrowableHandler;
class ArticleSchema extends Base {
class Arsc extends Base {
public function __construct($aUpdate)
{
@ -26,6 +26,48 @@ class ArticleSchema extends Base {
return $this->oDog->$sName($aArg[0]);
}
public function tu($aParam)
{
$iId = $aParam["aOption"][1] ?? 0;
$sThumbUse = $aParam["aArg"][1] ?? "";
if ($iId == "?") {
return "/thumbUse__[id?last] [a,b,c]";
}
if (!$sThumbUse) {
return "空值不可以";
}
if (!$iId) {
$iId = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first()?->id;
}
$oArticleSchema = ModelArticleSchema::where("id", $iId)->first();
if (!$oArticleSchema) {
return "没有这个id的数据";
}
$sOpt = $oArticleSchema->opt;
$aOpt = json_decode($sOpt, true);
$aThumbUse = explode(",", $sThumbUse);
$aOpt["thumb_use"] = $aThumbUse;
$oArticleSchema->opt = $aOpt;
$oArticleSchema->save();
$aResult = [
"id" => $oArticleSchema->id,
"code" => $oArticleSchema->code,
"opt" => $oArticleSchema->opt,
];
return $this->toJson($aResult);
}
public function last()
{
$iLastId = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first()?->id;

View File

@ -0,0 +1,177 @@
<?php
namespace App\Services\Tg\Hook\Mod;
use App\Models\ArticleSchema as ModelArticleSchema;
use App\Models\ArticleCache as ModelArticleCache;
use App\Models\ArticleCacheTime as ModelArticleCacheTime;
use App\Services\Tg\Hook\Dog;
use App\Services\Article\CacheTg as ServiceArticleCacheTg;
use App\Services\Article\Schema as ServiceArticleSchema;
use App\Services\Article\Cmd as ServiceArticleCmd;
use App\Services\TomTool\Flow;
//use App\Services\HttpQueue;
use App\Services\TomTool\TelegramVdb;
use App\Services\TomTool\ThrowableHandler;
use Illuminate\Database\QueryException;
use RuntimeException;
use App\Services\TomTool\HttpV2;
use App\Services\Cron\ArticleSchema as CronArticleSchema;
class Article extends Base {
private $oDog;
private $aUpdate;
public function __construct($aUpdate)
{
$this->oDog = new Dog(new ModelArticleSchema());
$this->oDog->_setDogName("articleSchema");
$this->oDog->_setStrField(["content"]);
$this->aUpdate = $aUpdate;
}
public function __call($sName, $aArg)
{
return $this->oDog->$sName($aArg[0]);
}
public function test_cron_saveAuto()
{
$r = ServiceArticleSchema::make()->cron_saveAuto();
return $r;
}
public function build_test_ttcp($aParam)
{
$oArticleCodeFirst = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
$aArg["sArticleCode"] = $oArticleCodeFirst->code;
$aArg["sFromCode"] = 'ttcp';
$aArg["sFromName"] = '天天测评';
$aArg["sFromUrl"] = 'ttcp.loc';
$aArg["sFromGroup"] = 'vue_md_ceping';
$aParam["aArg"][1] = json_encode($aArg);
$r = $this->build_test($aParam);
}
public function build_test($aParam)
{
$aJson = $aParam["aArg"];
$sJson = implode(" ", $aJson);
$aJson = json_decode($sJson, true);
$sShell = $this->aUpdate["shell"] ?? '';
$aJson["isTest"] = true;
$url = $_ENV["APP_URL"]."/api/article/build";
$r = HttpV2::make($url)->enableJsonSend()->setData($aJson)->send();
$a = json_decode($r, true);
if ($sShell !== "cmd") {
$oTelegramVdb = TelegramVdb::make("master");
foreach ($a["aData"] as $aa) {
$oTelegramVdb->send($aa);
}
}
echo "标题:".$a["aData"]["title"] ?? "?";
echo "<br>";
echo $a["aData"]["content"] ?? "?";
exit;
}
public function build_test_case($aParam)
{
$aArg["sArticleCode"] = 'ffq_tg::20251028113221';
$aArg["sFromCode"] = 'ttcp';
$aArg["sFromName"] = '天天测评';
$aArg["sFromUrl"] = 'ttcp.loc';
$aArg["sFromGroup"] = 'vue_md_ceping';
return $this->toJson($aArg);
}
public function cmdReset($aParam)
{
$xId = $aParam["aArg"][1] ?? "first";
if ($xId == "?") {
return "#cmdRe [xId:first]";
}
if ($xId == "first") {
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
} else {
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->where("id", $xId)->first();
}
$oModelArticleSchema->enable_sync = true;
$oModelArticleSchema->save();
$bool = ServiceArticleCmd::start($oModelArticleSchema->code)->reset();
return $bool;
}
public function cmdGet($aParam)
{
$xId = $aParam["aArg"][1] ?? "first";
if ($xId == "?") {
return "#cmdGet [xId:first]";
}
if ($xId == "first") {
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
} else {
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->where("id", $xId)->first();
}
return json_decode($oModelArticleSchema->cmd, true);
}
public function schemaGet($aParam)
{
$xId = $aParam["aArg"][1] ?? "first";
if ($xId == "?") {
return "#schemaGet [xId:first]";
}
if ($xId == "first") {
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
} else {
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->where("id", $xId)->first();
}
$aSchema = json_decode($oModelArticleSchema->schema, true);
$sMsg = json_encode($aSchema, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
return $sMsg;
}
public function cacheAdd($aParam)
{
$sFromGroupCode = $aParam["aOption"][1] ?? "ffq_tg_a";
$sContent = implode(' ', $aParam["aArg"]);
$r = ServiceArticleCacheTg::start()->add($sFromGroupCode, $sContent);
return $r;
}
// public function save($aParam)
// {
// $r = ServiceArticleSchema::make()->save();
//
// return $r;
// }
}

126
config/system.php Executable file
View File

@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => env('APP_TIMEZONE', 'UTC'),
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB